#K73367. Palindrome Checker
Palindrome Checker
Palindrome Checker
Given a string, determine whether it is a valid palindrome. A string is considered a palindrome if, after removing all non-alphanumeric characters and converting all letters to lowercase, it reads the same forward and backward. Formally, if \( s \) is the processed string, then it must satisfy \( s = s^R \), where \( s^R \) is the reverse of \( s \).
You will be given multiple strings, and for each string, you need to output YES
if it is a valid palindrome, otherwise output NO
.
inputFormat
The first line of input contains an integer \( n \) representing the number of test strings. Then follow \( n \) lines, each containing a string \( s_i \) which may include spaces, punctuation, and special characters.
outputFormat
For each input string, print a line containing YES
if the string is a valid palindrome according to the given rules, or NO
otherwise.
3
A man, a plan, a canal: Panama
race a car
Was it a car or a cat I saw?
YES
NO
YES
</p>