#C11450. Permutation of a Palindrome
Permutation of a Palindrome
Permutation of a Palindrome
Given a string, determine if any permutation of the string is a palindrome. A string is a permutation of a palindrome if it can be rearranged to form a palindrome. A key observation is that in a palindrome, each character must appear an even number of times, except possibly one character which can appear an odd number of times. In mathematical terms, for a string S, if we let \( f(c) \) denote the frequency of character \( c \), then S is a permutation of a palindrome if:
\[ \sum_{c\in S} \mathbf{1}_{\{f(c) \bmod 2 \neq 0\}} \leq 1 \]
Note that the check should be case-insensitive and all spaces should be ignored.
inputFormat
The input consists of a single line containing a string s. Spaces may appear in the string and should be ignored. The comparison should be case-insensitive.
outputFormat
Output a single line: True
if the string is a permutation of a palindrome, or False
otherwise.
Tact Coa
True