Skip to content

Instantly share code, notes, and snippets.

@Pierian-Data
Created December 1, 2017 01:43
Show Gist options
  • Save Pierian-Data/a17fd7357aeb919306864fe435e6ed15 to your computer and use it in GitHub Desktop.
Save Pierian-Data/a17fd7357aeb919306864fe435e6ed15 to your computer and use it in GitHub Desktop.
def profit(stock_prices):
if len(stock_prices) < 2:
return "Hey I need more prices!"
min_stock_price = stock_prices[0]
max_profit = 0
for price in stock_prices:
min_stock_price = min(min_stock_price,price)
comparison_profit = price - min_stock_price
max_profit = max(max_profit,comparison_profit)
return max_profit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment