#K37022. Rearrange to Palindrome
Rearrange to Palindrome
Rearrange to Palindrome
You are given a string s consisting of lowercase English letters. Your task is to determine whether the characters of the string can be rearranged to form a palindrome.
A string is a palindrome if it reads the same forward and backward. Mathematically, a rearrangement is possible if and only if at most one character appears an odd number of times. In terms of a formula, if we let \(f(c)\) be the frequency of character \(c\) in the string, then a palindrome can be formed if:
\(\sum_{c \in \text{alphabet}} \mathbf{1}_{\{f(c) \text{ is odd}\}} \le 1\)
Output YES
if a palindrome can be formed, and NO
otherwise.
inputFormat
The input consists of a single line containing a non-empty string s
consisting of lowercase English letters.
outputFormat
Output a single line with YES
if the string can be rearranged into a palindrome, or NO
otherwise.
aabbcc
YES