#C13677. Palindrome Permutation
Palindrome Permutation
Palindrome Permutation
Given a string s
consisting of lowercase letters, determine if any permutation of the string can form a palindrome. In other words, check if it is possible to rearrange the characters of s
such that the resulting string is a palindrome.
A string is a palindrome if it reads the same backward as forward. A necessary and sufficient condition for a permutation of the string to form a palindrome is that at most one character appears an odd number of times. Formally, if we denote by \(f(c)\) the frequency of character \(c\) in the string, then the string can be rearranged into a palindrome if:
$$ \sum_{c\in \text{alphabet}}\left[ f(c) \bmod 2 \neq 0 \right] \leq 1 $$inputFormat
The input consists of a single line containing the string s
. The string contains only lowercase English letters (a-z) and may be empty.
outputFormat
Output True
if some permutation of the string can form a palindrome; otherwise, output False
. The output should be printed on the standard output.
aabb
True