#K62327. Rearrange to Palindrome
Rearrange to Palindrome
Rearrange to Palindrome
Given a string s
, determine whether its characters can be rearranged to form a palindrome. A string can be rearranged to form a palindrome if and only if the number of characters that have an odd frequency is at most one, i.e., \(\leq 1\).
For example:
s = "civic"
can be rearranged to "civic" which is a palindrome, so the answer isYES
.s = "ivicc"
can be rearranged to "civic", so the answer isYES
.s = "hello"
cannot be rearranged into a palindrome, so the answer isNO
.
Your task is to implement a program that reads a string from standard input and prints YES
if the string can be rearranged into a palindrome; otherwise, it prints NO
.
inputFormat
The input consists of a single line containing the string s
. The string may be empty and will consist of ASCII characters.
outputFormat
Output a single line containing the string YES
if the characters of s
can be rearranged to form a palindrome; otherwise, output NO
.
civic
YES