Created
October 13, 2021 14:33
-
-
Save deniscapeto/f67c6aa5553f4fc68d00ae593c779ab2 to your computer and use it in GitHub Desktop.
get_most_profit_from_stock_quotes
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 get_most_profit_from_stock_quotes(quotes): | |
max_profit = 0 | |
for idx, day_quote in enumerate(quotes): | |
max_gain_day = 0 | |
lower_limit = idx+1 | |
for next in quotes[lower_limit::]: | |
gain = next - day_quote | |
if gain > max_gain_day: | |
max_gain_day = gain | |
max_profit += max_gain_day | |
return max_profit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment