Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created February 26, 2020 16:24
Show Gist options
  • Save deque-blog/a7e3a59a2bb4824a05d9f11757045c29 to your computer and use it in GitHub Desktop.
Save deque-blog/a7e3a59a2bb4824a05d9f11757045c29 to your computer and use it in GitHub Desktop.
def maxProfit(prices: List[int]) -> int:
end_time = len(prices)
max_profit = 0
for buy_time in range(end_time):
for sell_time in range(buy_time+1, end_time):
profit = prices[sell_time] - prices[buy_time]
if profit > max_profit:
max_profit = profit
return max_profit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment