Problem title
Difficulty
Avg time to solve

Minimize Malware Spread II
Hard
30 mins
Prefix Suffix Search
Easy
20 mins
Infix To Postfix
Easy
20 mins
Network Delay Time
Easy
20 mins
Round Robin Scheduling
Easy
15 mins
Disconnect the ‘GRID’ by removing the minimum number of cities
Hard
10 mins
Best Meeting Point
Easy
15 mins
Encode and Decode
Easy
15 mins
Create Array
Easy
15 mins
Rahul And Minimum Subarray
Moderate
--
5

Malamal Weekly

Difficulty: EASY
Contributed By
Avg. time to solve
20 min
Success Rate
80%

Problem Statement

Nowadays, Ninja tries his luck every week in buying a lottery ticket just by selecting some random numbers. But this time he got some insider information about the lottery that how a winner is selected this time.

So the information is that the lottery chart contains the number in form of an array/list 'ARR' and for winning the lottery Ninja has to find out the largest element with minimum frequency from that chart or we can say 'ARR'.

So help our Ninja in selecting the number, so that Ninja is able to win the lottery.

Formally, find the largest number with minimum frequency from the given 'ARR'.

Example:
You have given an array {2, 2, 5, 50, 1} so in this array ‘50’ is the largest number with minimum frequency.
Input Format:
The first line contains an integer 'T', which denotes the number of test cases or queries to be run. Then, the 'T' test cases follow. 

The first line of each test case contains a positive integer 'N' denoting the size of the array.

The second line of each test case contains an array ‘ARR[i]’ containing ‘N’ number of values.
Output Format:
For each test case, print the largest number with minimum frequency.
Note:
You do not need to print anything. It has already been taken care of. Just implement the given function.

Constraints:

1 <= T <= 10^2
1 <= N <= 10^3
1 <= ARR[i] <= 10^9

Where ‘T’ represents the number of test cases and ‘N’ represents the size of array and ‘ARR[i]’ represents the elements of array.

Time Limit: 1sec

Sample Input 1:

2
5
9 9 9 2 5
5
5 5 4 6 4 

Sample Output 1:

5
6

Explanation For Sample Input 1:

In first test case, ‘5’ is the size of the array. In the second line elements of the array are given so according to this array ‘5’ and ‘2’ are the elements with minimum frequency but as ‘5 is larger than ‘2’, So, ‘5’ is the answer.

In the second test case, ‘6’ is the number with the smallest frequency.

Sample Input 2 :

2
3
1 1 1
5
50 50 1 30 30

Sample Output 2 :

1
1

Explanation For Sample Input 2:

In the first test case, ‘3’ is the size of the array and all elements are '1'. So, ‘1’ is the answer.

In the second test case, ‘1’ is the number with the smallest frequency.
Reset Code
Full screen
copy-code
Console