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

My Code…

http://www.codechef.com/viewsolution/4087597

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 :)

**HAPPY CODING**


  [1]: http://ideone.com/xqGJeC
1 Like

I am still getting wrong answer.
Code: http://www.codechef.com/viewsolution/4167985
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: