Problem
A phrase is a palindrome if it reads the same forwards and backwards once you lowercase every letter and throw away everything that is not a letter or digit. Given a string s, return true if it is a palindrome.
Example 1
- Input
- "A man, a plan, a canal: Panama"
- Output
- true
- Why
- "amanaplanacanalpanama"
Example 2
- Input
- "race a car"
- Output
- false
- Why
- "raceacar"
Example 3
- Input
- " "
- Output
- true
- Why
- nothing left, which counts
Try to solve it without building a cleaned-up copy of the string.
Constraints
0 <= s.length <= 2 * 10^5s contains only printable ASCII characters.Use O(1) extra space.