#K43092. Rearranging Characters for a Palindrome
Rearranging Characters for a Palindrome
Rearranging Characters for a Palindrome
You are given a string s
. Your task is to determine whether its characters can be rearranged in such a way that the resulting string is a palindrome.
A palindrome is a string that reads the same forwards and backwards. For a string to be able to form a palindrome, the following condition must hold:
$$\text{number of characters with odd frequency} \le 1$$
In other words, at most one character may appear an odd number of times, while all other characters must appear an even number of times.
inputFormat
The input consists of a single line containing the string s
.
You should read the input from stdin
.
outputFormat
Output a single line to stdout
containing either YES
if the string can be rearranged to form a palindrome, or NO
otherwise.
civic
YES