You are viewing a single comment's thread. Return to all comments →
My solution in python:
def candies(n, arr): # Write your code here results = [1 for _ in range(n)] # ascending for i in range(1, n): if arr[i] > arr[i - 1]: results[i] = results[i - 1] + 1 for i in range(n - 2, -1, -1): if arr[i] > arr[i + 1]: results[i] = max(results[i + 1] + 1, results[i]) return sum(results)
Candies
You are viewing a single comment's thread. Return to all comments →
My solution in python: