#K91907. Palindromic Rearrangement
Palindromic Rearrangement
Palindromic Rearrangement
You are given a string s. Your task is to determine whether the characters of s can be rearranged to form a palindrome. A string can be rearranged to form a palindrome if and only if at most one character has an odd frequency. In other words, if we denote by \(odd\_count\) the number of characters that appear an odd number of times, then a palindrome arrangement is possible if and only if \(odd\_count \le 1\).
For example, the string "carrace" can be rearranged to "racecar", which is a palindrome, so the answer is "Yes". On the other hand, the string "daily" cannot be rearranged into a palindrome, so the answer is "No".
Your program should read multiple test cases from stdin
and output the result for each case to stdout
.
inputFormat
The first line of input contains an integer T representing the number of test cases. Each of the following T lines contains a single non-empty string s.
Input is read from stdin
.
outputFormat
For each test case, output "Yes" if the characters in the string can be rearranged to form a palindrome. Otherwise, output "No". Each answer should be printed on a new line to stdout
.
3
carrace
daily
aab
Yes
No
Yes
</p>