#C5970. Palindrome Rearrangement Checker
Palindrome Rearrangement Checker
Palindrome Rearrangement Checker
You are given a string s
consisting only of lowercase English letters. Your task is to determine whether it is possible to rearrange the characters of the string to form a palindrome.
A string is a palindrome if it reads the same backwards and forwards. A necessary and sufficient condition for a string to be rearrangeable into a palindrome is that at most one character has an odd frequency. In mathematical terms, if we denote the frequency of each character by \( f(c) \), the string can be rearranged into a palindrome if and only if $$ \sum_{c}\left[ f(c) \;\%\; 2 \neq 0 \right] \leq 1, $$ where \(\%\) denotes the modulo operation.
Input and Output: The program reads the input from stdin
and writes the output to stdout
.
inputFormat
A single line containing a string s
that consists only of lowercase English letters.
outputFormat
Output a single line: "YES" if the string can be rearranged to form a palindrome, otherwise output "NO".## sample
carrace
YES