Two Pointers
LC #125Easy
Valid Palindrome
Two Pointers
AmazonMicrosoftGoogleAppleMetaProblem
A string is a palindrome if, after removing non-alphanumeric characters and lowercasing, it reads the same forward and backward.
stringtwo-pointers
Constraints
- ›1 ≤ s.length ≤ 2 × 10⁵
- ›s consists only of printable ASCII characters
Example
Input
s = "A man, a plan, a canal: Panama"Output
trueWhy
After removing non-alphanumeric and lowercasing: "amanaplanacanalpanama" — reads the same both ways