Easy
005Valid Palindrome
Return true if s is a palindrome after converting uppercase letters to lowercase and removing all non-alphanumeric characters. Otherwise, return false.
EXAMPLES
Example 1
Input
{
"s": "A man, a plan, a canal: Panama"
}
Output
trueFUNCTION SHAPE
s: string→boolSOLUTION NOTE
Open on LeetCode ↗We basically use two pointers. We initialize from both ends of the string. We loop while the string is more than 1 character long. We iterate until the left and right pointers are alphanumeric. We then check if the lowercase equivalents are equal, if not this string is not a palindrome. Otherwise these 2 characters match and we continue.