 All Problems
Valid Palindrome
easy
two pointers
strings
facebook
microsoft
amazon

A phrase is a palindrome if, after converting all uppercase to lowercase and removing all non-alphanumeric characters, it reads the same forwards and backwards.

Given a string s, return true if it is a palindrome, false otherwise.

Example 1:

Input: A man a plan a canal Panama
Output: true

Example 2:

Input: race a car
Output: false

Constraints:

  • 1 ≤ s.length ≤ 2 × 10⁵
  • s consists only of printable ASCII characters

Input format: One line — the string (spaces included).

Output format: true or false

Run to check your code against the sample cases, or submit to run every case