#K50827. Palindrome Rearrangement
Palindrome Rearrangement
Palindrome Rearrangement
Given a string s consisting of lowercase English letters, determine whether its characters can be rearranged to form a palindrome.
A string is a palindrome if it reads the same forwards and backwards. In order to rearrange a string into a palindrome, the frequency of each character must satisfy the following condition:
\(\text{At most one character can have an odd frequency}\).
For example, the string carrace
can be rearranged into racecar
, so the answer is YES
. However, hellos
cannot form a palindrome, so the answer would be NO
.
inputFormat
The input consists of a single line containing a string \(s\) composed of lowercase English letters.
outputFormat
Output a single line containing YES
if the string can be rearranged into a palindrome, or NO
otherwise.
carrace
YES
</p>