please tell me the way to print each time k elements without popping them
How do we print each time k elements?
it is not possible to print k elements of priority_queue without poping the elements of priority_queue
then how shall i print them?
to print elements of queue you have to pop them
for this question “top-k-most-frequent-numbers-in-a-stream”
you can also use map based approach
i have shared the code link below
Reference Code
although, the question seemed to be a little tough but u have written a simplified code which made me understand it easily. Thank you sir!