Occurrence sum
Submissions: 419   Accuracy:

6.99%

  Max. Score:

100

Given an array arr of size N. The task is to find sum of of highest and lowest frequency of elements in the array.
Note: The lowest occurrence here for an element means 1.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains N, size of array. Second line contains N space separated elements.

Output:
For each test case, print the required result in new line.

Constraints:
1<=T<=10
1<=N<=105
1<=arr[i]<=105

Example:
Input:

1
6
5 2 2 1 2 3

Output:
4

Explanation:
Testcase1:
The respective frequencies of the elements are as follows :-
5->1
2->3
1->1
3->1
The highest frequency is 3 and lowest is 1  so 3+1= 4 is the answer.


to report an issue on this page.