#K47682. Can Form Palindrome
Can Form Palindrome
Can Form Palindrome
Given a string s
consisting only of lowercase English letters, determine whether its characters can be rearranged to form a palindrome.
A palindrome is a string that reads the same forwards and backwards. One necessary and sufficient condition for a string to be rearranged into a palindrome is that at most one character appears an odd number of times. Formally, if the frequency of each character is given by \( f(c) \), then the string can form a palindrome if and only if:
\[ \sum_{c \in s} [f(c) \bmod 2 \neq 0] \leq 1 \]Write a program that reads the string from standard input and prints YES
if it can be rearranged into a palindrome, and NO
otherwise.
inputFormat
The input consists of a single line containing a string s
(1 ≤ |s| ≤ 106), which is composed of lowercase English letters only.
outputFormat
Output a single line containing either YES
or NO
depending on whether the given string can be rearranged into a palindrome.
aaabbbb
YES