count of maximum showing wrong answer but satisfying many test cases



Count of maximum is showing wrong answer, however all the test cases i tried gives correct answer
Please tell where i am doing wrong
this is my solution


alt text

I guess that’s not clearing your whole array but clearing only the first element.

And I don’t understand why you are sorting the array. I have changed a little bit your code (actually removed some parts).
This gets AC :

Vote if it was helpful.


Try this testcase : 1 1 1


Thanks after seeing the editorial i also got the point that there is no need of sorting the array then i solved the problem by creating frequency map much the same way u r doing…
I was just thinking that my code was giving correct answer for all test cases i tried but still showing wrong answer.
I was not able to figure out problem in my code


my original code is giving right answer for this testcase as well
1 3


Different compilers we are using - i guess.