Solve the rating candy problem in leetcode, O(n) time and O(1) space.