#K69802. Rearrange Array for Even Occurrences

    ID: 33167 Type: Default 1000ms 256MiB

Rearrange Array for Even Occurrences

Rearrange Array for Even Occurrences

You are given T test cases. For each test case, you are provided with a list of n integers. Your task is to determine whether it is possible to rearrange the array so that every distinct integer occurs an even number of times.

Formally, let \( f(x) \) denote the frequency of an integer \( x \) in the array. The answer is YES if and only if \( f(x) \) is even for every integer \( x \) present in the array, and NO otherwise.

Note: Rearrangement of the array is allowed, however, the rearrangement is only possible if the frequency condition is met.

inputFormat

The first line contains an integer T, the number of test cases. For each test case, the first line contains an integer n denoting the number of elements in the array. The second line contains n space-separated integers representing the array.

outputFormat

For each test case, output a single line containing YES if it is possible to rearrange the array such that every integer appears an even number of times; otherwise, output NO.## sample

2
4
1 2 2 1
5
1 2 2 1 3
YES

NO

</p>