Created
February 26, 2020 16:24
-
-
Save deque-blog/a7e3a59a2bb4824a05d9f11757045c29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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