Guest User

Untitled

a guest
Jan 20th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. def measure(array):
  2. spaces = len(array)
  3. left = array.copy()
  4. right = array.copy()
  5. max_left = max_right = 0
  6.  
  7. for i in range(spaces):
  8. left[i] = max_left = max(left[i], max_left)
  9. right[spaces-i-1] = max_right = max(right[spaces-i-1], max_right)
  10.  
  11. return sum([min(l, r) - h for h, l, r in zip(array, left, right)])
  12.  
  13. print(measure([6,0,6,1,5]))
Add Comment
Please, Sign In to add comment