#K93012. Palindrome Permutation Checker
Palindrome Permutation Checker
Palindrome Permutation Checker
You are given a string s
. Determine if any permutation of s
can form a palindrome.
A palindrome is a word or phrase that reads the same backward as forward. A string can be rearranged into a palindrome if and only if at most one character has an odd frequency. In other words, if we denote by \( f(c) \) the frequency of a character \( c \), then the string can form a palindrome if:
\( \sum_{c \in s} [f(c) \bmod 2] \le 1 \)
Output YES if the string can form a palindrome, and NO otherwise.
inputFormat
The input consists of a single line containing the string s
. The string may be empty.
outputFormat
Output a single line containing either YES or NO indicating whether any permutation of s
can form a palindrome.
civic
YES