#C6674. Can Form Palindrome
Can Form Palindrome
Can Form Palindrome
You are given a string s. Determine whether the characters of s can be rearranged to form a palindrome.
A palindrome is a string that reads the same forwards and backwards. In order for a string to be rearranged into a palindrome, at most one character can have an odd frequency. Formally, if we let \(f(c)\) denote the frequency of character \(c\) in the string, the necessary and sufficient condition is:
\[ \sum_{c \in \Sigma} \mathbf{1}_{\{f(c)\ \%\ 2\ \neq\ 0\}} \leq 1 \]
The input string is provided via standard input (stdin) and the answer should be printed to standard output (stdout) as either YES
or NO
.
inputFormat
A single line contains a string s. The string may be empty and consists of ASCII characters. Input is provided via standard input (stdin).
outputFormat
Print 'YES' if the characters of the string can be rearranged to form a palindrome; otherwise, print 'NO'. The output should be written to standard output (stdout).## sample
aab
YES