#C5425. Can Form a Palindrome?
Can Form a Palindrome?
Can Form a Palindrome?
Given a string s consisting of visible ASCII characters, determine whether its characters can be rearranged to form a palindrome. A string is said to be able to form a palindrome if and only if at most one character appears an odd number of times.
Mathematically, given a string s and for each character c let \( f(c) \) denote its frequency, then the string can form a palindrome if and only if:
\[ \sum_{c\in s} {\bf 1}_{(f(c) \bmod 2 \neq 0)} \leq 1 \]Output YES
if the string can be rearranged to form a palindrome, otherwise output NO
.
inputFormat
The input consists of a single line containing a non-empty string s
of visible ASCII characters.
outputFormat
Output a single line: YES
if the characters of s
can be rearranged to form a palindrome; otherwise, output NO
.
aabbcc
YES