#K66252. Finding the Most Productive Team
Finding the Most Productive Team
Finding the Most Productive Team
You are given T test cases. Each test case consists of a sequence of tasks completed by various teams. For every task, the team that completed it is given in chronological order.
Your task is to determine the team with the highest productivity (i.e. the highest number of tasks completed). In the event of a tie, the team whose first task appears earlier in the list is considered more productive.
Team IDs are positive integers. Read input from stdin and print the answer for each test case to stdout, with one answer per line.
Note: The determination is based on the frequency of task completion. If two teams have equal counts, the team that appears first wins.
inputFormat
The first line contains a single integer T, the number of test cases. This is followed by T test cases. Each test case begins with an integer N denoting the number of tasks. The next line contains N space-separated integers representing the IDs of the teams that completed the tasks in chronological order.
For example:
3 5 1 2 1 3 2 4 4 4 4 4 6 2 3 2 3 2 3
outputFormat
For each test case, output one integer on a new line which is the ID of the most productive team according to the criteria described above.
For example, the output for the sample input above would be:
1 4 2## sample
3
5
1 2 1 3 2
4
4 4 4 4
6
2 3 2 3 2 3
1
4
2
</p>