#K86407. Palindrome Permutation
Palindrome Permutation
Palindrome Permutation
Given a string s
, determine whether its characters can be rearranged to form a palindrome. A string can be rearranged into a palindrome if and only if at most one character appears an odd number of times. Mathematically, this condition can be expressed as:
$$\sum_{c \in \Sigma} \bigl[\text{count}(c) \bmod 2 \neq 0\bigr] \leq 1$$
For example, the string "aaabbbb" can be rearranged to form a palindrome (e.g., "bbaaabb"), whereas "cdefghmnopqrstuvw" cannot.
inputFormat
The input consists of a single line containing a non-empty string s
of lowercase letters.
outputFormat
Output a single line with the string YES
if the input string can be rearranged to form a palindrome, and NO
otherwise.
aaabbbb
YES