#K61917. Palindrome Rearrangement
Palindrome Rearrangement
Palindrome Rearrangement
Given a string s, determine if its characters can be rearranged to form a palindrome.
A palindrome is a sequence that reads the same backward as forward. In order for a string to be rearranged into a palindrome, the frequency of each character must be even, except for at most one character which can appear an odd number of times. Mathematically, if \( f(c) \) represents the frequency of character \( c \), then the necessary and sufficient condition is:
\( \sum_{c} (f(c) \bmod 2) \leq 1 \)
inputFormat
The input consists of a single line containing the string s.
outputFormat
Output a single line with the answer: YES
if the string can be rearranged into a palindrome, otherwise NO
.
aabb
YES