#C13363. Can Form Palindrome
Can Form Palindrome
Can Form Palindrome
You are given a string s
. Your task is to determine whether any permutation of s
can form a palindrome.
A palindrome is a string that reads the same backward as forward. For a string to be rearranged into a palindrome, at most one character can appear an odd number of times.
In mathematical terms, given the frequency count \( f(c) \) for each character \( c \) in a normalized form of the string (ignoring case and non-alphanumeric characters), the string can be rearranged into a palindrome if and only if
\[ \sum_{c} \mathbf{1}_{f(c) \% 2 \neq 0} \leq 1 \]Read the input from standard input (stdin) and output the answer to standard output (stdout) as either True
or False
.
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 any permutation of the string can form a palindrome, otherwise output False
. The output should be printed as a single line to standard output.
Tact Coa
True