#C2698. Palindromic Rearrangement Check

    ID: 46042 Type: Default 1000ms 256MiB

Palindromic Rearrangement Check

Palindromic Rearrangement Check

You are given several strings. For each string, determine whether its characters can be rearranged to form a palindrome.

A string is said to be able to form a palindrome if at most one character has an odd frequency. Formally, given a string \( s \), let \( f(c) \) be the frequency of character \( c \) in \( s \). Then \( s \) can be rearranged to form a palindrome if and only if:

[ \sum_{c \in s} \mathbb{1}_{{f(c)\text{ is odd}}} \le 1 ]

Your task is to process \( T \) test cases. For each test case, output "YES" if the string's characters can be rearranged to form a palindrome; otherwise, output "NO".

inputFormat

The first line of input contains an integer \( T \) representing the number of test cases. Each of the following \( T \) lines contains a non-empty string \( s \) consisting of lowercase English letters.

For example:

3
civic
ivicc
hello

outputFormat

For each test case, output a single line containing "YES" if the string can be rearranged into a palindrome, and "NO" otherwise.

For the input example above, the output should be:

YES
YES
NO
## sample
1
a
YES

</p>