Problem of the day
Given array āARR = { 1, 2, 3, 3, 3, 3, 4, 4, 4, 1, 2 ,0}ā and āK = 4ā
The first line of input contains an integer āTā denoting the number of test cases.
The next āTā lines represent the āTā test cases.
The first line of input contains two space-separated integers āNā and āKā. Where āNā denotes the number of elements in array āARRā and āKā is given integer number.
The second line of input contains the āNā space-separated integer which denotes the element of array āARRā and āKā is given a second integer number.
For every test case, print all elements of āARRā which occur more than or equals to āN/Kā times in āARRā.
Output for each test case will be printed in a separate line.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 10^2
1 <= K <= N <= 5*10^3 ( N is multiple of K)
-10^9 <= ARR[i] <= 10^9
Where āTā represents the number of test cases, āNā is the number of elements in array āARRā , āKā denotes an integer. āARR[i]ā represents the value of the number at āiā position in āARRā.
Time Limit: 1 sec
2
8 4
1 1 2 1 2 4 3 4
6 6
1 1 1 2 2 2
1 2 4
1 2
Test Case 1:
Given array āARR = { 1, 1, 2, 1, 2, 4, 3, 4 }ā and āK = 2ā.
Only 1, 2, 4 has frequency more than or equal to āN/K' = 8/4= 2.
Test Case 2:
Given array āARR = { 1, 1, 1, 2, 2, 2 }ā and āK = 6ā.
āN/K = 6/6 = 1ā so ā1ā and ā2ā both have frequency more than ā1ā.
2
9 3
1 1 1 2 2 2 2 2 2
6 6
1 2 1 2 3 4
1 2
1 2 3 4
Test Case 1:
Given array āARR = { 1, 1, 1, 2, 2, 2, 2, 2, 2 }ā and āK = 3ā.
Both 1, 2 has frequency more than or equal to āN/K' = 9/3= 3.
Test Case 2:
Given array āARR = { 1, 2, 1, 2, 3, 4 }ā and āK = 6ā.
āN/K = 6/6 = 1ā so ā1ā, '2', '3' and ā4' all have frequency more than ā1ā.