Whats Wrong with K-most frequent element question?

Even after trying different approaches, No test case has passed, please help!

@abhir26 your code is fine, problem is that in the problem statement order of output is not given when frequency of more than 1 elements are same and that is why your code is giving wrong output.
It will be updated shortly try this problem later.

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.