#C12108. Check Palindrome (Ignoring Non-Alphanumeric Characters)
Check Palindrome (Ignoring Non-Alphanumeric Characters)
Check Palindrome (Ignoring Non-Alphanumeric Characters)
Given a string s, determine whether it is a palindrome. In this problem, only alphanumeric characters are considered and case is ignored. For example, the string "A man a plan a canal Panama" is a palindrome because if you remove spaces and punctuation and convert all letters to lowercase, it reads the same forward and backward.
Mathematically, if we define a filtered string \( s' \) such that \[ s' = \text{concat}(c_i \text{ for each } c_i \in s \text{ if } c_i \text{ is alphanumeric, transformed to lowercase}) \] then the string is a palindrome if and only if \[ s' = \text{reverse}(s') \]
inputFormat
The input consists of a single line containing a string s which may include spaces, punctuation, and other characters.
outputFormat
Output a single line containing True
if the string is a palindrome (after filtering), or False
otherwise.
A man a plan a canal Panama
True