need hint in this question, unable to think how to print the data using heap and map.
Heap = need hint in this question
hi @arpitranjan641_d2edeaf633b10b54,
1 <- no of testcases
5 2 <- no of elements and value of k
5 1 3 5 2 <- running stream data
first we got 5
so top 2 most freqent nos are 5 only as we have only one element so we print only one
ans= 5
then we got 1
so top 2 most frequent nos are 1 and 5 (in increasing order)
ans= 5 1 5
then we got 3
so top 2 most frequent nos are 1 3 (increasing order)
ans= 5 1 5 1 3
then we got 5
so top 2 most frequent nos are 5 and 1(smallest one )
ans=5 1 5 1 3 5 1
ans so on
i hope you got the point
reference code --> https://ide.codingblocks.com/s/640329
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.