Valid Palindrome

Easy

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

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

Example 1

isPalindrome()
Input
s = "A man, a plan, a canal: Panama"
Output
true

Why

"amanaplanacanalpanama" is a palindrome.

Example 2

isPalindrome()
Input
s = "race a car"
Output
false
Constraints
1 <= s.length <= 2 * 10^5
s consists only of printable ASCII characters.

Topics

StringsTwo Pointers

Implement isPalindrome in the editor and return the answer — printing it is never graded.