#K1981. Palindrome Permutation
Palindrome Permutation
Palindrome Permutation
You are given a list of strings. For each string, determine whether its characters can be rearranged to form a palindrome.
A string can be rearranged into a palindrome if at most one character has an odd frequency count. For example, the string civic
is already a palindrome, and ivicc
can be rearranged to civic
. However, hello
cannot be rearranged into a palindrome.
Print YES
if it is possible to form a palindrome, otherwise print NO
.
inputFormat
The input begins with an integer T denoting the number of test cases. Each of the next T lines contains a single string s.
Note: A test case can be an empty string.
outputFormat
For each test case, output a single line containing YES
if the string can be rearranged to form a palindrome. Otherwise, output NO
.
4
civic
ivicc
hello
racecar
YES
YES
NO
YES
</p>