I got a wrong answer:

Input: [1,2,4,4,3]

Output: 10

Expected: 9

my output is 1+2+3+3+1 = 10. and

I think OJ's is 1+2+3+2+1 = 9

how can the third child has more candies than the fourth?

because the requirement is "Children with a higher rating get more candies than their neighbors", the third child does not have higher rating than the fourth does.