Frequency Game
Submissions: 1237   Accuracy:

69.53%

  Difficulty: Easy   Marks: 2
Associated Course(s):   Fork Java

Given an array A of size N. The elements of the array consists of positive integers. You have to find the largest element with minimum frequency.

Input Format: First line of input contains number of testcases T. For each testcase there will be two lines. First line contains N, next line contains N elements separated by spaces.

Output Format: For each testcase, print the largest element with minimum frequency.

User Task:
Your task is to complete the provided function LargButMinFreq(A, n) which accepts array A and n. Hence you have to return the largest element with minimum frequency.

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

Example:
Input:

1
5
2 2 5 50 1

Output:
50

Explanation :
Testcase 1:
All elements are having frequency 1 except 2. 50 is the maximum element with minimum frequency.

Note: use HashMap to compute the element and its frequency.

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

Author: Dhiman Mayank


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.