count of maximum showing wrong answer but satisfying many test cases

count
maxcount

#1

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


#2

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 : https://ideone.com/QkmrSM

Vote if it was helpful.


#3

Try this testcase : 1 1 1


#4

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


#5

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


#6

Different compilers we are using - i guess. https://ideone.com/TiVvE1