Skip to content

Instantly share code, notes, and snippets.

@deniscapeto
Created October 13, 2021 14:33
Show Gist options
  • Save deniscapeto/f67c6aa5553f4fc68d00ae593c779ab2 to your computer and use it in GitHub Desktop.
Save deniscapeto/f67c6aa5553f4fc68d00ae593c779ab2 to your computer and use it in GitHub Desktop.
get_most_profit_from_stock_quotes
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