#K78492. Element Pair Check
Element Pair Check
Element Pair Check
You are given \(T\) test cases. For each test case, you are provided with an integer \(N\) representing the number of elements in an array, followed by \(N\) integers. Your task is to determine whether every distinct element in the array appears exactly twice. In other words, for every element \(x\) in the array, the frequency must satisfy: $$f(x)=2.$$
If the condition holds, output YES
; otherwise, output NO
.
inputFormat
The input begins with an integer T denoting the number of test cases. Each test case consists of two lines:
- The first line contains an integer N, the number of elements in the array.
- The second line contains N space-separated integers.
outputFormat
For each test case, print a single line containing YES
if every distinct element appears exactly twice; otherwise, print NO
.
1
4
1 2 2 1
YES
</p>