#K59957. Can Form Palindrome
Can Form Palindrome
Can Form Palindrome
Given a string s
consisting of lowercase English letters, determine whether its characters can be rearranged to form a palindrome.
A palindrome is a string that reads the same forwards and backwards. It is known that a string can be rearranged into a palindrome if and only if at most one character appears an odd number of times. In mathematical terms, if we denote by \( odd \) the number of characters having an odd frequency, then the necessary and sufficient condition is:
\[ odd \leq 1 \]Your task is to implement a solution that reads the input string from standard input and outputs either Yes
if the string can be rearranged into a palindrome, or No
otherwise.
inputFormat
The input consists of a single line containing a non-empty string s
which comprises only lowercase English letters.
For example:
aabb
outputFormat
Output a single word: Yes
if the characters of s
can be rearranged to form a palindrome, and No
otherwise.
For instance, for the input aabb
, the output should be Yes
.
aabb
Yes