#C6050. Palindrome Checker Ignoring Non-Alphanumeric Characters
Palindrome Checker Ignoring Non-Alphanumeric Characters
Palindrome Checker Ignoring Non-Alphanumeric Characters
You are given multiple lines of input, each containing a string. For every string (except the line "END" which indicates termination), determine if it is a palindrome.
A palindrome is a sequence of characters that reads the same forward and backward after removing all characters that are not alphanumeric and converting all letters to lowercase. In other words, for a string s, let:
\( \text{filtered}(s) = \) all characters c in s such that c is alphanumeric, converted to lowercase.
If \( \text{filtered}(s) \) equals its reverse, then s is a palindrome. Output "YES" if it is a palindrome and "NO" otherwise.
The program should read input from stdin and output results to stdout.
inputFormat
The input consists of several lines. Each line contains a string. The input terminates when a line with exactly "END" is encountered, which should not be processed.
Note: The strings may contain spaces, punctuation, and mixed case letters.
outputFormat
For each input line (except the "END" line), output a line containing either "YES" if the processed string is a palindrome or "NO" otherwise.
## sampleA man, a plan, a canal, Panama
No 'x' in Nixon
random string
END
YES
YES
NO
</p>