#C14444. Valid Palindrome Checker
Valid Palindrome Checker
Valid Palindrome Checker
Given a string s
, determine if it is a valid palindrome. In this problem, a string is a palindrome if, after converting all uppercase letters to lowercase and removing all non-alphanumeric characters, it reads the same backward as forward.
The challenge is to consider only alphanumeric characters and ignore cases. For example, the string "A man, a plan, a canal: Panama" is a valid palindrome, whereas "race a car" is not.
You need to read the input from standard input (stdin) and print the result to standard output (stdout) for each test case.
inputFormat
The first line of input contains an integer T (1 ≤ T ≤ 100), representing the number of test cases. Each of the following T lines contains a string s
consisting of printable ASCII characters. The string may include spaces and punctuation.
outputFormat
For each test case, output a single line that contains either True
or False
. Output True
if the string is a valid palindrome after converting it to lowercase and removing all non-alphanumeric characters; otherwise, output False
.
1
A man, a plan, a canal: Panama
True
</p>