#K561. Palindrome Checker
Palindrome Checker
Palindrome Checker
Given a string s
, determine whether s
is a palindrome. A string is considered a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward.
Note: Only alphanumeric characters should be considered. That is, ignore punctuation, spaces, and special characters. In mathematical terms, if we define the filtered string as \(f(s) = \text{concatenation of } c \text{ for } c \in s \text{ if } c \text{ is alphanumeric, converted to lowercase}\), then the string is a palindrome if \(f(s) = f(s)^{\text{rev}}\).
For example:
A man, a plan, a canal: Panama
is a palindrome.race a car
is not a palindrome.
inputFormat
The input consists of a single line containing the string s
. The string may include spaces, punctuation, and mixed case letters.
outputFormat
Output True
if the input string is a palindrome according to the above definition; otherwise, output False
.
A man, a plan, a canal: Panama
True