#C2978. Palindromic Anagram Checker
Palindromic Anagram Checker
Palindromic Anagram Checker
You are given a word. Your task is to determine whether the characters of the word can be rearranged to form a palindrome. A string can be rearranged to form a palindrome if at most one character appears an odd number of times. In mathematical terms, if \(odd\_count\) is the number of characters with odd frequencies, then the condition to form a palindrome is:
\[ \text{odd\_count} \leq 1 \]
For each test case, output YES
if it is possible to form a palindrome by rearranging the letters, otherwise output NO
.
inputFormat
The first line of input contains a single integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains a single word.
Input is read from standard input (stdin).
outputFormat
For each test case, output a single line containing either YES
or NO
depending on whether the word can be rearranged to form a palindrome. The output is printed to standard output (stdout).
3
civic
ivicc
hello
YES
YES
NO
</p>