#K79567. Smallest Even Occurrence
Smallest Even Occurrence
Smallest Even Occurrence
Given a sequence of integers for each test case, your task is to determine the smallest integer that appears an even number of times. In other words, for each test case and for every integer ( x ) in the array, let ( f(x) ) be the frequency of ( x ). You need to find the smallest ( x ) such that ( f(x) \bmod 2 = 0 ). If no integer meets this condition, output ( -1 ).
For example, if the array is [4, 3, 2, 2, 3], then 3 appears twice and 2 appears twice; the answer is 2 because it is smaller than 3. If the array is [1, 2, 3, 4] (each appears once), then the answer is -1.
inputFormat
The input consists of multiple test cases. The first line contains an integer ( T ), which is the number of test cases. For each test case, the first line contains an integer ( n ) denoting the number of elements in the array, followed by a line containing ( n ) space-separated integers.
outputFormat
For each test case, output a single line with the smallest integer that appears an even number of times. If no such integer exists, print ( -1 ).## sample
2
5
4 3 2 2 3
4
1 2 3 4
2
-1
</p>