Wrong Solution in Editorial

Editorial Solution is wrong
A : [1, 2, 2, 2, 1]
should give answer 8 (considering we can give same candies for same rating)
but editorial gives answer as 7. Some test cases are also wrong.
They give 1 candy if ratings are same

They mentioned, if a neighbor rating is higher than you, then you’ll get more candies.
But here neighbor has the same rating as you, so you can give one candy.

Click here to start solving coding interview questions