#C1020. Palindrome Checker
Palindrome Checker
Palindrome Checker
Given a string s, determine whether it is a palindrome, considering only alphanumeric characters and ignoring cases. A palindrome is a word, phrase, or sequence that reads the same backward as forward. In this problem, you are required to filter out all non-alphanumeric characters and then compare the resulting string with its reverse.
Note: The filtering process can be summarized by the formula:
\( s' = \text{lowercase}(\{ c \in s : c \text{ is alphanumeric} \}) \)
The string is a palindrome if:
\( s' = \text{reverse}(s') \)
inputFormat
The input consists of a single line containing a string s. The string may include spaces, punctuation, and mixed cases.
Input Format:
One line containing the string s.
outputFormat
Output a single line: True
if the given string is a palindrome after filtering out non-alphanumeric characters and converting to lowercase, otherwise output False
.
Output Format:
One line containing either True or False## sample
A man, a plan, a canal: Panama
True