Top k most frequent number in a stream (using heaps)

how to solve this using heaps???

@agarwalbhavya06
hello bhavya,
why heap? heap will be very inefficient for this problem we will need to pop k elemnt everytime to print it and then again we need them to push them back.

@aman212yadav
so how to approach this problem??

@agarwalbhavya06
pls refer this -> https://www.geeksforgeeks.org/find-top-k-or-most-frequent-numbers-in-a-stream/

@aman212yadav
this gfg approach uses mapping and hashing concepts…
so i will better try this problem after learning these concepts…

@agarwalbhavya06
:+1: :+1: :+1:

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.