#C12614. Valid Palindrome Checker
Valid Palindrome Checker
Valid Palindrome Checker
You are given a string s
. Your task is to determine whether the string is a valid palindrome.
A string is considered a palindrome if it reads the same backward as forward after ignoring case and ignoring all non-alphanumeric characters.
In mathematical terms, let \( s \) be the input string. Remove every character that is not an alphanumeric character, and convert the remaining characters to lowercase to get \( s' \). The string is a palindrome if and only if \( s' = (s')^R \), where \( (s')^R \) is the reverse of \( s' \).
For example, the string "A man, a plan, a canal, Panama!" becomes "amanaplanacanalpanama" which is the same as its reverse.
inputFormat
The input consists of a single line containing the string s
. The string may contain spaces, punctuation, or other non-alphanumeric characters.
outputFormat
Output a single line: True
if the input string is a palindrome, otherwise False
.
A man, a plan, a canal, Panama!
True