Valid Palindrome
Problem statement
Given a string s, ignore every character other than ASCII letters and digits, and compare letters without regard to case.
Return true if the remaining characters read identically from left to right and right to left. Otherwise, return false. A string with no remaining characters is a palindrome.
Function
isPalindrome(s: String) → booleanExamples
Example 1
s = "A man, a plan, a canal: Panama"return = trueIgnoring spaces, punctuation and case leaves amanaplanacanalpanama, which reads the same in both directions.
Example 2
s = "race a car"return = falseThe retained string is raceacar; its fourth character from the left is e, while its fourth character from the right is a.
Example 3
s = " "return = trueRemoving the space leaves no characters, so the result is true.
Example 4
s = "0P"return = falseDigits are retained. After lowercasing, 0p is not a palindrome.
Constraints
1 <= s.length <= 2 * 10^5.scontains only printable ASCII characters.