can anyone tell me why it's expected to be 4 not 5?
Because you don't have to give children with the same rating the same amount of candy. So the solution for [1,2,2] could be [1,2,1] which sums up to 4.
got it. thanks
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.