Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution(object):
- def maxProfit(self, prices):
- """
- :type prices: List[int]
- :rtype: int
- """
- if not prices:
- return 0
- profit = 0
- min_val = prices[0]
- for p in prices[1:]:
- if p > min_val:
- profit += p - min_val
- min_val = p
- else:
- min_val = p
- return profit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement