smj007

Untitled

Jun 19th, 2022
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. class Solution:
  2.     def maxProfit(self, prices: List[int]) -> int:
  3.         max_profit = 0
  4.         for i in range(len(prices) - 1):
  5.             max_profit += max(prices[i+1] - prices[i], 0)
  6.         return max_profit
Advertisement
Add Comment
Please, Sign In to add comment