Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. # you can write to stdout for debugging purposes, e.g.
  2. # print("this is a debug message")
  3.  
  4. def solution(A):
  5. # write your code in Python 3.6
  6. if A == []:
  7. return 0
  8. cost = [0] * (len(A)-1)
  9. for i in range(len(A)-1):
  10. cost[i] = A[i+1] - A[i]
  11. s = 0
  12. maxS = 0
  13. for c in cost:
  14. if s > 0:
  15. s += c
  16. else:
  17. s = c
  18. if s > maxS:
  19. maxS = s
  20. return max(maxS, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement