
In an Allstate mobile app text-processing utility, implement a function that determines whether a string is a palindrome when special characters are ignored. Comparison should be case-insensitive, and only letters and digits should be considered.
strue if the cleaned string reads the same forward and backwardfalse otherwiseA character should be included only if it is alphanumeric (a-z, A-Z, 0-9). Spaces, punctuation, and symbols must be ignored.
Example 1
s = "A man, a plan, a canal: Panama"trueamanaplanacanalpanama, which is a palindrome.Example 2
s = "race a car"falseraceacar, which is not the same in reverse.0 <= len(s) <= 10^5s may contain letters, digits, spaces, punctuation, and symbolss = "A man, a plan, a canal: Panama"OutputTrueWhyIgnoring spaces and punctuation and lowercasing gives `amanaplanacanalpanama`, which reads the same forward and backward.s = "race a car"OutputFalseWhyAfter filtering and lowercasing, the string becomes `raceacar`, which is not a palindrome.s = ".,"OutputTrueWhyThere are no alphanumeric characters, so the cleaned string is empty, which is considered a palindrome.0 <= len(s) <= 10^5s may contain uppercase letters, lowercase letters, digits, spaces, punctuation, and symbolsOnly alphanumeric characters should be consideredCharacter comparison must be case-insensitivedef is_palindrome_ignoring_special(s):