#K59332. Palindrome Checker for Alphabetic Strings
Palindrome Checker for Alphabetic Strings
Palindrome Checker for Alphabetic Strings
In this problem, you are given one or more strings. Your task is to determine whether each string is a palindrome when considering only its alphabetic characters. All non-alphabetic characters should be ignored, and the comparison should be case-insensitive.
A string s is considered a palindrome if:
$$ filtered(s) = (filtered(s))^R $$
where filtered(s)
is the string formed by removing all non-alphabetic characters from s and converting the remaining characters to lowercase, and (filtered(s))^R
denotes its reverse.
For each test case, output YES
if the string is a palindrome, and NO
otherwise.
inputFormat
The first line of the input contains a single integer T (1 ≤ T ≤ 100), the number of test cases. Each of the following T lines contains a non-empty string, which may include spaces, punctuation, or other symbols.
The string will have a maximum length of 1000 characters.
outputFormat
For each test case, output a single line containing either YES
if the given string (after filtering) is a palindrome, or NO
otherwise.
3
a.b,a
race car
hello
YES
YES
NO
</p>