Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def maxProfit(self, prices: List[int]) -> int:
- """
- """
- buy_index = 0
- sell_index = 1
- max_profit = 0
- while sell_index < len(prices):
- current_profit = prices[sell_index] - prices[buy_index]
- max_profit = max(current_profit, max_profit)
- if prices[sell_index] < prices[buy_index]:
- buy_index = sell_index
- sell_index += 1
- return max_profit
Advertisement
Add Comment
Please, Sign In to add comment