#K67617. Palindrome Permutation Checker
Palindrome Permutation Checker
Palindrome Permutation Checker
Given a sentence S, determine if its characters (ignoring spaces) can be rearranged to form a palindrome. A string can be rearranged into a palindrome if at most one character has an odd frequency. In other words, let \( f(c) \) denote the frequency of character \( c \) in the sentence (after removing spaces). The string can form a palindrome if and only if
\[\#\{ c : f(c) \bmod 2 = 1 \} \leq 1\]
You are given multiple test cases. For each test case, output "YES" if the sentence's characters can be rearranged into a palindrome, and "NO" otherwise.
inputFormat
The input begins with an integer \( T \) \((1 \leq T \leq 100)\), representing the number of test cases. Each of the following \( T \) lines contains a sentence \( S \) consisting of letters and spaces. Note that spaces should be ignored when determining the possibility of rearranging into a palindrome.
outputFormat
For each test case, output a single line containing either "YES" or "NO". "YES" indicates that the characters of the sentence can be rearranged to form a palindrome, and "NO" otherwise.
## sample3
race car
a man a plan a canal panama
hello world
YES
YES
NO
</p>