#K75472. Can Form Palindrome
Can Form Palindrome
Can Form Palindrome
You are given a string s
consisting of lowercase alphabets. Your task is to determine whether the characters of s
can be rearranged to 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 at most one character has an odd frequency. In mathematical terms, if we denote the number of characters with odd occurrences as \(\text{odd_count}\), then the condition is:
[ \text{odd_count} \leq 1 ]
If the condition is satisfied, output YES
; otherwise, output NO
.
inputFormat
The input is given from stdin and consists of a single line containing a string s
made up of lowercase alphabets.
outputFormat
Output a single line to stdout containing either YES
if the string can be rearranged to form a palindrome, or NO
if it cannot.
aabbcc
YES