#C10432. Taco Palindrome Check

    ID: 39637 Type: Default 1000ms 256MiB

Taco Palindrome Check

Taco Palindrome Check

Given a string, determine whether it can be rearranged to form a palindrome. A palindrome is a string that reads the same backwards as forwards. The key observation is that a string can be rearranged into a palindrome if and only if at most one character appears an odd number of times. In mathematical terms, if we denote the count of characters with an odd frequency as \(\text{oddCount}\), then the string can form a palindrome if and only if \(\text{oddCount} \leq 1\).

Your task is to process multiple test cases. For each string, output YES if it 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 non-empty string consisting of lowercase letters.

Example:

2
aabb
abc

outputFormat

For each test case, output a single line containing YES if the string can be rearranged to form a palindrome, or NO otherwise.

Example:

YES
NO
## sample
2
aabb
abc
YES

NO

</p>