#K55847. Palindrome Rearrangement
Palindrome Rearrangement
Palindrome Rearrangement
You are given a string s. Your task is to determine whether any permutation of s can form a palindrome. A palindrome is a string that reads the same backward as forward. For example, the string civic
is a palindrome and ivicc
can be rearranged to civic
which is a palindrome, while hello
cannot be rearranged to form any palindrome.
The 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. Use this property to decide your answer.
Mathematically, let ( f(c) ) denote the frequency of character ( c ) in the string, then the string is palindromic rearrangable if and only if [ \sum_{c} \Bigl[ f(c) \mod 2 \Bigr] \le 1. ]
inputFormat
Input consists of a single line containing the string s. The string will consist of lowercase English letters only.
outputFormat
Output a single line containing either YES
or NO
. Output YES
if the string can be rearranged into a palindrome, and NO
otherwise.## sample
civic
YES