


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
Approach: The basic idea is that to find the occurrence of ‘x’, and if the occurrence of ‘x’ is more than or equals to the ‘n/k’ then it should be a part of the answer.
Algorithm:
Approach: The basic idea is that, store the frequency of each element of ‘ARR’ in a hashmap/dictionary, then find which element has a frequency greater or equals to the ‘N/K’.
The algorithm will be -