#C12170. Valid Palindrome Checker
Valid Palindrome Checker
Valid Palindrome Checker
Given a string s
, determine whether it is a valid palindrome considering only alphanumeric characters and ignoring cases. Formally, after removing all characters that are not alphanumeric and converting all letters to lowercase, the string should satisfy the condition \(s[i] = s[n-i-1]\) for all valid indices \(i\), where \(n\) is the length of the filtered string.
For example:
- If
s = "A man, a plan, a canal, Panama"
, after filtering and converting it becomes "amanaplanacanalpanama", which is a palindrome. - If
s = "Hello, World!"
, the result is "helloworld" which is not a palindrome.
Your task is to implement the solution that reads an input string from standard input and prints True
if it is a palindrome, or False
otherwise.
inputFormat
The input consists of a single line containing the string s
.
outputFormat
Print a single line: True
if the string is a valid palindrome after ignoring non-alphanumeric characters and case, otherwise print False
.
True