Explain the sample test case

Explain the sample test case

hello @t.prateek98
Whenever we input a number, we’ve to output k most frequent numbers in decreasing order, and if frequency of two or more numbers is same print them in increasing order, and if numbers present till now is less than k print all of them following the same criteria for frequency.

Let’s discuss the given example:
1
5 2
5 1 3 5 2
Here t = 1
for the given test case n = 5, k = 2
so let’s see what happend when each number is inputted:-
when the first number 5 is inputted, the numbers present are
5 with frequency 1,
so we only print 5
when 1 is inputted
the numbers present are
5 with frequency 1,
1 with frequency 1,
two numbers with same frequency present, so we output them in increasing order:
We print 1 5
when 3 is inputted,
the numbers present are
5 with frequency 1,
1 with frequency 1,
1 with frequency 1,
three numbers with same frequency present, so we output k of them in increasing order:
We print 1 3
when 5 is inputted
the numbers present are
5 with frequency 2,
1 with frequency 1,
1 with frequency 1,
highest freq is 2, and 2nd highest is 1(for 1, 3 but we can print only 2 numbers, and we’ve to print same frequency numbers In increasing order,
We print 5 1
When 2 is inputted:
the numbers present are
5 with frequency 2,
1 with frequency 1,
1 with frequency 1,
2 with frequency 1
highest freq is 2, and 2nd highest is 1(for 1, 2, 3 but we can print only 2 numbers, and we’ve to print same frequency numbers In increasing order,
We print 5 1
so printed numbers are
5 1 5 1 3 5 1 5 1

give me some another test cases .I dont get my mistake.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.