#C7516. Palindrome Checker: Verify and Return Result
Palindrome Checker: Verify and Return Result
Palindrome Checker: Verify and Return Result
Given a string, determine whether it is a palindrome. A palindrome is defined as a string that reads the same forwards and backwards after removing all non-alphanumeric characters and ignoring case differences. You need to process multiple test cases from standard input. For each test case, output YES
if the string is a palindrome; otherwise, output NO
.
Mathematical Note: When considering the string \( s \), we define the cleaned string \( c(s) = \text{lowercase}(\text{alphanumeric characters of } s) \). The condition for \( s \) being a palindrome is:
\( c(s) = \text{reverse}(c(s)) \).
inputFormat
The first line of input contains an integer \( n \) representing the number of test cases. Each of the following \( n \) lines contains a string to be checked.
outputFormat
For each test case, output a single line containing YES
if the input string is a palindrome; otherwise, output NO
.
3
A man a plan a canal Panama
Was it a car or a cat I saw
This is not a palindrome
YES
YES
NO
</p>