#K66747. Permutation of Palindrome
Permutation of Palindrome
Permutation of Palindrome
You are given a string s
consisting of lowercase English alphabets only. Your task is to determine whether any permutation of the string s
can form a palindrome.
A palindrome is a string that reads the same forward and backward. A 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. In mathematical terms, let \(\text{odd_count}\) be the count of characters with odd frequencies, then we require:
[ \text{odd_count} \leq 1 ]
Your program should read the input from standard input (stdin
) and write the output to standard output (stdout
).
inputFormat
The input consists of a single line containing the string s
.
Constraints:
s
contains only lowercase English letters ('a'-'z').- The length of
s
can be zero or more.
outputFormat
Output a single line containing YES
if any permutation of s
can form a palindrome, or NO
otherwise.
civic
YES