Easy Python Solution | Candy
\nclass Solution:\n    def candy(self, ratings: List[int]) -> int:\n        length = len(ratings)\n        candies = [1] * length\n        for i in range(1, len
```\nclass Solution:\n    def candy(self, ratings: List[int]) -> int:\n        length = len(ratings)\n        candies = [1] * length\n        for i in range(1, length):\n            if ratings[i] > ratings[i-1] and candies[i] <= candies[i-1]:\n                candies[i] = candies[i-1] + 1\n        for i in range(length - 2, -1, -1):\n            if ratings[i] > ratings[i + 1] and candies[i] <= candies[i+1]:\n                candies[i] = candies[i+1] + 1\n        return sum(candies)\n```
['Python', 'Python3']