Difference between highest and lowest occurrence
Submissions: 2190   Accuracy:

21.41%

  Difficulty: Basic   Marks: 1

Given an array, the task is to find the difference between highest occurrence and lowest occurrence of any number in an array.

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 a integer N and the second line contains N space separated array elements.

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

Constraints:
1<=T<=100
1<=N<=105
1<=A[i]<=105

Example:
Input:

2
3
1 2 2
6
1 2 2 3 3 3

Output:
1
2

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arun Tyagi
Author: deactjustCalvin


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.