Elsevier content-processing services may need to validate whether a user-provided phrase reads the same forward and backward. Implement isPalindrome to determine whether a string is a palindrome after ignoring case and all characters that are not letters or digits.
Given a string s, return True if the sequence of alphanumeric characters in s, compared without regard to case, is identical from left to right and right to left. Otherwise, return False.
The function must not modify the input string. An empty string or a string containing no alphanumeric characters is considered a palindrome.
Example 1
Input: s = "A man, a plan, a canal: Panama"
Output: True
Ignoring punctuation and spaces, the string becomes amanaplanacanalpanama, which reads identically in both directions.
Example 2
Input: s = "Elsevier"
Output: False
The normalized string starts with e and ends with r, so it cannot be a palindrome.
0 <= len(s) <= 2 * 10^5s contains printable ASCII characters.def isPalindrome(s):