This file contains 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_max_profit_parker(stock_prices_yesterday): | |
# make sure we have at least 2 prices | |
if len(stock_prices_yesterday) < 2: | |
raise IndexError('Getting a profit requires at least 2 prices') | |
# we'll greedily update min_price and max_profit, so we initialize | |
# them to the first price and the first possible profit | |
min_price = stock_prices_yesterday[0] | |
max_profit = stock_prices_yesterday[1] - stock_prices_yesterday[0] |