text: class Solution(object):
      def candy(self, ratings):
          """
          :type ratings: List[int]
          :rtype: int
          """
          nums = [1] * len(ratings)
          for i in range(1, len(ratings)):
              if ratings[i] > ratings[i - 1]:
                  nums[i] = nums[i - 1] + 1
  
          for i in range(len(ratings) - 1, 0, -1):
              if ratings[i - 1] > ratings[i]:
                  nums[i - 1] = max(nums[i - 1], nums[i] + 1)
  
          return sum(nums)
  