LeetCode: Candy

Approach 1: First give every child one candy. Then, first, left to
right, if the rate of ith child > the rate of i-1th child, the number
of candy of ith child is the number of candy of i-1th child + 1,
otherwise, do not update. Second, right to left, if the rate of ith
child > the rate of i+1th child AND the number of candy of ith child <
the number of candy of i+1th child, the number of candy of ith child is
the number of candy of i+1th child +1.