Most Frequent Element (MFREQ) - Getting wrong answer

Can anyone tell me where my code is wrong?

You provided the wrong link. Please copy address of link from mysubmissions page.

link is only for you. please provide the public link.

The link is updated now.

Try tweaking your code such that in case multiple answers are possible, your code prints the one occurring first.


Compilation Successful
Input (stdin)
5 1
1 1 5 5 5
1 5 2
Your Output

Try that your code prints 1 for this (which is occurring first). If your code works after that, then its an issue with test cases.

Check the constraints for K.

I am sorry dear, I am unable to help further. I spent ~ 4 hours on the code, checking test cases and thinking of corner cases. But your code passed all test cases which I had. I don’t think I would be able to assist you further. Hope your doubt gets clarified soon.