#K9716. Palindrome Reordering
Palindrome Reordering
Palindrome Reordering
You are given a string s
consisting of lowercase letters and digits. Your task is to determine whether the characters of s
can be rearranged to form a palindrome.
A string is a palindrome if it reads the same forwards and backwards. A necessary and sufficient condition for a string to be rearranged into a palindrome is that at most one character has an odd frequency count. In mathematical terms, if we let \( f(c) \) denote the frequency of character \( c \) in the string, then the string can be rearranged into a palindrome if and only if:
[ \sum_{c} \mathbf{1}_{{f(c) ;mod; 2 \neq 0}} \le 1 ]
Print YES
if it is possible to reorder the string into a palindrome, otherwise print NO
.
inputFormat
The input consists of a single line containing the string s
composed of lowercase letters and digits.
outputFormat
Output a single line: YES
if the string can be rearranged into a palindrome, and NO
otherwise.
aabbcc
YES