In that test case, the number of candies to be given would be: 1-2-1 (total 4)
The rules say that each child must get a bigger amount of candy if he/she has a higher rating than the neighboring kids. The 3rd kid doesn't have any kid beside him/her with a lower rating, so optimally you can just give that kid a single candy and it would still be compliant to the rules.
I really think this describe is sick as the children with the same weight should have the same amount of candies in common.
I have the same question.
I think it is unfair that a child gets less candies than his neighbor with equal rating.
@franz.sarmiento I understand the problem's description and solution, but it looks really really unreasonable(fair) to me!
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.