#K12396. Palindromic Rearrangement

    ID: 23681 Type: Default 1000ms 256MiB

Palindromic Rearrangement

Palindromic Rearrangement

Given a string s, determine whether it is possible to rearrange its characters to form a palindrome.

A string can be rearranged to form a palindrome if at most one character appears an odd number of times. For example, the string civic is already a palindrome, and the string ivicc can be rearranged to form civic which is a palindrome, while the string hello cannot form any palindrome permutation.

The problem may be formally stated as:

Given a string \( s \), determine if there exists a permutation of \( s \) that is a palindrome. A necessary and sufficient condition is that at most one character has an odd count in \( s \).

inputFormat

The input consists of a single line containing a non-empty string \( s \) consisting of lowercase English letters.

Example:

civic

outputFormat

Output a single line: YES if the characters of the string can be rearranged to form a palindrome, or NO otherwise.

Example:

YES
## sample
civic
YES

</p>