#C6775. Taco: Palindrome Rearrangement Checker
Taco: Palindrome Rearrangement Checker
Taco: Palindrome Rearrangement Checker
You are given an integer n and a string s of length n. Your task is to determine whether the characters of the string can be rearranged to form a palindrome under the special condition that each character must appear an even number of times.
If it is possible to rearrange s so that every character has an even frequency, output YES
; otherwise, output NO
.
The input begins with an integer T
denoting the number of test cases. Each test case consists of a line containing an integer n and the string s separated by a space. For each test case, you should print the answer on a new line.
inputFormat
The first line of input contains a single integer T
(the number of test cases). Each of the following T
lines contains a test case in the following format:
n s
Here, n
is the length of the string and s
is a string consisting of characters. It is guaranteed that the length of s
is exactly n
.
outputFormat
For each test case, output a single line with either YES
if the string can be rearranged so that every character appears an even number of times, or NO
otherwise.
3
4 abba
6 aabbcc
4 abcd
YES
YES
NO
</p>