Top k most frequent numbers

i am able to understand the question and sample test cases if we get frequency more than one then what we have to do and if we create heap then how to print the element after every iteration?

@aditikandhway,
If you haven’t encountered k distinct elements till now, then print all distinct elements, else print the top k frequent ones only.
Hint, don’t use heap.

than which data structure should i use for implementation?

@aditikandhway,
You can use set and maps.

i haven’t studied map till now so is there any other method to solve this question?

i haven’t studied map till now so is there any other method to solve this question?

@aditikandhway,
You can skip this problem for now, and come back to it latter. I really like the map approach, and recommend you do it ones you have done maps.

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.