#C4762. Palindromic Permutation
Palindromic Permutation
Palindromic Permutation
You are given a string \( s \) consisting only of lowercase English letters. Your task is to determine whether any permutation of \( s \) can form a palindrome.
A string is a palindrome if it reads the same backward as forward. A necessary and sufficient condition for a string to be rearranged into a palindrome is that the number of characters with odd frequencies does not exceed one, i.e., \[ \text{odd_count} \leq 1 \]
For example, consider the string "aabbccc". The letter 'c' appears three times (odd frequency) and the letters 'a' and 'b' appear twice (even frequency), so there is only one odd frequency count. Thus, a palindromic permutation exists.
inputFormat
The input consists of a single line containing the string \( s \). The string will only contain lowercase English letters and may be empty.
outputFormat
Output a single line containing YES
if a permutation of the string can form a palindrome, or NO
otherwise.
aabbcc
YES