Laptop Recommendation solution codechef
Chef wants to buy a new laptop. However, he is confused about which laptop to buy out of 1010 different laptops. He asks his NN friends for their recommendation. The ithith friend recommends the Chef to buy the AithAithlaptop (1≤Ai≤10)(1≤Ai≤10).
Chef will buy the laptop which is recommended by maximum number of friends. Determine which laptop Chef buys.
Print CONFUSED
if there are multiple laptops having maximum number of recommendations.
Laptop Recommendation solution codechef Input Format
- The first line contains a single integer TT – the number of test cases. Then the test cases follow.
- The first line of each test case contains an integer NN – the number of Chef’s friends.
- The second line of each test case contains NN space-separated integers A1,A2,…,ANA1,A2,…,AN where AiAi denotes the recommendation of the ithith friend.
Output Format
For each test case, output in a single line, the laptop which has the maximum number of recommendations. Print CONFUSED
if there are multiple laptops having maximum number of recommendations.
You may print each character of CONFUSED
in uppercase or lowercase (for example, Confused
, coNFused
, CONFused
will be considered identical).
Constraints Laptop Recommendation solution codechef
- 1≤T≤2001≤T≤200
- 1≤N≤10001≤N≤1000
- 1≤Ai≤101≤Ai≤10
Sample Input 1
4
5
4 4 4 2 1
7
1 2 3 4 5 6 6
6
2 2 3 3 10 8
4
7 7 8 8
Sample Output 1
4
6
CONFUSED
CONFUSED
Explanation Laptop Recommendation solution codechef
Test case 1: Laptop 44 has the maximum number of recommendations. Therefore, Chef will buy the 4th4th laptop.
Test case 2: Laptop 66 has the maximum number of recommendations. Therefore, Chef will buy the 6th6th laptop.
Test case 3: Laptops 22, 33 have the maximum number of recommendations. Therefore, Chef will still be CONFUSED
.
Test case 4: Laptops 77, 88 have the maximum number of recommendations. Therefore, Chef will still be CONFUSED
.