#K6761. Palindrome Rearrangement
Palindrome Rearrangement
Palindrome Rearrangement
Given a string s, determine whether its characters can be rearranged to form a palindrome. A palindrome reads the same forwards and backwards.
A string can be rearranged into a palindrome if and only if the number of characters that appear an odd number of times in s is at most one. Mathematically, let \( oddCount \) be the number of characters with an odd frequency, then the condition is:
\( oddCount \leq 1 \)
For example:
- If
s = "civic"
, then the answer isYes
. - If
s = "ivicc"
, then the answer isYes
. - If
s = "hello"
, then the answer isNo
.
inputFormat
The input consists of a single line containing the string s. The string may contain lowercase English letters and can be empty.
outputFormat
Output a single line: Yes
if the string can be rearranged into a palindrome, otherwise No
.
civic
Yes