Top k most frequent in running stream

i know how to find the top k in array but can u please tell me how to deal with stream

this is no new thing in stream

stream means nos are given one by one and you have ans them

in this question your are given numbers and you have to answer after each no

i not able to get how to print the elements in sorted order if they are distinct in heap, can u please help me

from heap if you extract elements it will be always sorted

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.