#C10701. Most Frequent Integer in Each Test Case
Most Frequent Integer in Each Test Case
Most Frequent Integer in Each Test Case
You are given multiple test cases. For each test case, you have a list of integers. Your task is to determine which integer appears most frequently in the list. In case of a tie (i.e. if there are several integers that occur the maximum number of times), choose the smallest one.
Input Format: The first line contains an integer \(T\), denoting the number of test cases. Each test case starts with an integer \(N\) indicating the number of integers that follow. Then \(N\) integers are given, separated by spaces.
Output Format: For each test case, output the most frequent integer on a new line. In case of a tie, output the smallest integer among those with the highest frequency.
inputFormat
The first line of input contains an integer (T) representing the number of test cases. For each test case, the first integer (N) indicates the number of elements, followed by (N) integers separated by spaces.
outputFormat
For each test case, output a single line containing the most frequent integer. If multiple integers share the maximum frequency, output the smallest one.## sample
3
5 1 2 2 3 1
4 4 4 4
6 1 1 2 2 3 3
1
4
1
</p>