#C4612. Anagram of Palindrome Check
Anagram of Palindrome Check
Anagram of Palindrome Check
Given a string s, determine whether it is an anagram of a palindrome. A string is an anagram of a palindrome if its characters can be rearranged to form a palindrome. Equivalently, at most one character in the string can have an odd frequency.
For example, the string "carrace" can be rearranged to form "racecar", a palindrome, so the answer is YES. In contrast, the string "hello" cannot be rearranged into any palindrome, so the outcome is NO.
You are required to process multiple test cases. For each test case, output "YES" if the given string is an anagram of a palindrome, otherwise output "NO".
The solution should read the input from standard input (stdin) and print the result to standard output (stdout).
The mathematical condition for a string to be an anagram of a palindrome is that if we denote by \( f(c) \) the frequency of a character \( c \) in the string, then: \[ \sum_{c} \mathbf{1}_{\{f(c) \text{ is odd}\}} \leq 1 \]
inputFormat
The first line of the input contains an integer T
(1 ≤ T ≤ 105), the number of test cases.
Each of the following T lines contains a non-empty string s
(consisting of lowercase/uppercase letters) whose length does not exceed 105.
It is guaranteed that the total length of all strings does not exceed 106.
outputFormat
For each test case, output a single line containing "YES" if the string is an anagram of a palindrome, or "NO" otherwise.
## sample2
carrace
hello
YES
NO
</p>