""" Candy There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings. You are giving candies to these children subject to the following requirements: - Each child must have at least one candy. - Children with a higher rating get more candies than their neighbors. Return the minimum number of candies needed to distribute to the children. Example 1 Input: ratings = [4, 3, 5] Output: 5 Explanation: One valid distribution is [2, 1, 2]. Example 2 Input: ratings = [2, 3, 3] Output: 4 Explanation: One valid distribution is [1, 2, 1]. Constraints 1 <= len(ratings) <= 20_000 0 <= ratings[i] <= 20_000 Expected Complexity Time O(n) Space O(1) extra space """ def solution(ratings): pass print("Candy", end=" ") assert solution([4, 3, 5]) == 5, "example 1 failed" assert solution([2, 3, 3]) == 4, "example 2 failed" assert solution([1]) == 1, "single child failed" assert solution([1, 2, 3, 4]) == 10, "increasing ratings failed" assert solution([4, 3, 2, 1]) == 10, "decreasing ratings failed" assert solution([1, 0, 2]) == 5, "valley pattern failed" print("OK")