#K40032. Can Form Palindrome
Can Form Palindrome
Can Form Palindrome
You are given a string s. Your task is to determine whether the characters of s can be rearranged to form a palindrome. Recall, a palindrome is a string that reads the same forwards and backwards. The necessary and sufficient condition for a permutation of s to be a palindrome is that at most one character has an odd frequency.
This can be formally stated as: $$\sum_{i} \mathbf{1}\{f(i) \% 2 \neq 0\} \leq 1,$$ where \(f(i)\) denotes the frequency of the \(i\)-th character.
Input/Output: The input is taken from stdin
and the result is printed to stdout
.
inputFormat
The input consists of a single line containing a string s which may include spaces and other ASCII characters.
outputFormat
Output a single line: print True
if the characters of the string can be rearranged to form a palindrome, otherwise print False
.
civic
True