#C12345. Can Form Palindrome
Can Form Palindrome
Can Form Palindrome
Given a string s
, determine whether its characters can be rearranged to form a palindrome.
A string can be rearranged into a palindrome if at most one character has an odd frequency.
For example, aabb
can be rearranged into abba
which is a palindrome, while abc
cannot form any palindrome.
Note: The input is read from standard input and the output is written to standard output.
Mathematically, a string is rearrangeable to a palindrome if:
\[ \text{odd\_count} = \sum_{c \in \Sigma} \mathbb{1}(\text{freq}(c) \bmod 2 \neq 0) \leq 1. \]inputFormat
The input consists of a single line containing the string s
. The string may be empty.
outputFormat
Output a single line containing either True
if it is possible to rearrange the characters of s
to form a palindrome, or False
otherwise.
aabb
True