Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def measure(array):
- spaces = len(array)
- left = array.copy()
- right = array.copy()
- max_left = max_right = 0
- for i in range(spaces):
- left[i] = max_left = max(left[i], max_left)
- right[spaces-i-1] = max_right = max(right[spaces-i-1], max_right)
- return sum([min(l, r) - h for h, l, r in zip(array, left, right)])
- print(measure([6,0,6,1,5]))
Add Comment
Please, Sign In to add comment