I am unable to get the qn

can you please explain the sample output how the output is coming. i am unable to get that

1
5 2
5 1 3 5 2
so first 5 comes… till then only one number is present and we have to find top 2 frequent numbers so o/p is 5
then 1 comes so o/p is 1 5
then 3 comes and o/p is 1 3
then 5 comes… now we have 2 instances of 5… so o.p is 5 1
then 2 comes… so o/p is 5 1

thus overall o/p i 5 1 5 1 3 5 1 5 1

but for the frequency we need hashmap how using heaps only we can do it ?

u can refer this https://ide.codingblocks.com/s/594149

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.