
In the given array A[] = {1, 2, 2, 3, 3, 3,} 1 has occurred 1 times, 2 has occurred 2 times and 3 has occurred 3 times. So we will return 3 since it is the maximum number.
The first line contains a single integer ‘T’ denoting the number of test cases, then each test case follows.
The first line of each test case contains an integer ‘N’, denoting the number of integers.
The second line of each test case contains ‘N’ space-separated integers.
For each test case, print the highest number ‘X’ which has appeared ‘X’ a number of times.
Output for each test case will be printed in a separate line.
You are not required to print anything; it has already been taken care of. Just implement the function.
1 <= N <= 10^5
1<= array[i] <= 10^9
Time limit: 1 sec
Lets first Sort the array in descending order
Then we can perform the following steps:
We can also sort the array in ascending order and do the reverse of what is described in the above steps.
We will use a HashMap in this approach.