You are given an array of size N. You need to find elements which appear prime number of times in the array with minimum K frequency (frequency >= K).
The first line of the input contains a single integer T, denoting the number of test cases. Then T test case follows. Each testcase contains two lines of input:-
The size of the array N and minimum frequency K separated by a space.
The elements of the array separated by spaces.
For each testcase, print the elements that have prime frequency with their frequency >=K. Print the output in sorted order. If there are no such elements then print -1.
11 11 11 23 11 37 51 37 37 51 51 51 51
11 22 33
For testcase 1: 11's count is 4, 23 count 1, 37 count 3, 51 count 5. 37 and 51 are two number that appear prime number of time and frequencies greater than or equal to K=2.
For testcase 2: K=1, and all three elements occur extactly 1 times. Unfortunately, 1 is not prime, so we don't print any element. We, instead, print a -1.
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.