#K72447. Rearrange to Palindrome
Rearrange to Palindrome
Rearrange to Palindrome
You are given a string consisting solely of lowercase letters. Your task is to determine whether the characters of the string can be rearranged to form a palindrome. A palindrome is a string that reads the same forwards and backwards.
The problem can be summarized using the following concept:
For a string \(s\) of length \(n\), it is possible to form a palindrome if and only if at most one character appears an odd number of times. In other words, if the frequency of each character except possibly one is even, then the string can be rearranged into a palindrome.
You need to process multiple test cases. For each test case, you will be provided with a string, and you must output "YES" if the string can be rearranged into a palindrome, or "NO" otherwise.
inputFormat
The first line contains an integer \(t\) representing the number of test cases. Each of the following \(t\) lines contains a string \(s\) made up of lowercase alphabets.
Example:
3 carrace daily aab
outputFormat
For each test case, print a single line containing "YES" if the corresponding string can be rearranged into a palindrome, or "NO" if it cannot.
Example Output:
YES NO YES## sample
3
carrace
daily
aab
YES
NO
YES
</p>