Count of Maximum... Why my code is not accepted? Please help... :)

My Code…

One case that you are missing is the case of n = 1.

1 Like

Use MAP. That will be the most efficient way of coding this solution. Moreover if the elements were in the range of -ve numbers your algorithm may not work. I have coded using MAP and take a look at this

[1]. If you have any-doubt please do ask me :)


1 Like

I am still getting wrong answer.
Thanks a Lot… :slight_smile:

But A[i] is in the range [1,1000]. It never takes negative value.
Thanks… :slight_smile:

No it does not take -ve values. I know it. I have done the quesion. But suppose in case in an interview you are asked the same question with the constraints as -10^4 to 10^4?? You will have to use map. So this code works for both. If you dont understand the syntax please do ask me :slight_smile:

For that, I have to first learn map. So first of all I’ll see maps and then I’ll get back to you if I have any query.
Thanks for the help… :slight_smile: