#C3068. Rearrange to Palindrome
Rearrange to Palindrome
Rearrange to Palindrome
Given a string S
, determine whether it is possible to rearrange its characters to form a palindrome. A palindrome is a string that reads identically backward and forward. The necessary and sufficient condition for the existence of such a rearrangement is that at most one character appears an odd number of times. In other words, if we denote by \(c_i\) the frequency of the \(i\)-th character, then the string can form a palindrome if and only if
\(\sum_{i}(c_i \bmod 2) \leq 1\)
inputFormat
The input consists of a single line containing the string S
. The string may contain any printable characters and its length can be zero or more.
outputFormat
Output a single line with either YES
if the characters of the string S
can be rearranged to form a palindrome, or NO
if they cannot.
civic
YES