Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- prices = [9, 11, 8, 5, 7, 10]
- def buy_and_sell(stock_prices):
- largest_profit = 0
- for i in range(len(stock_prices)):
- for k in stock_prices[i:]:
- if k - stock_prices[i] > largest_profit:
- largest_profit = k - stock_prices[i]
- return largest_profit
- print(buy_and_sell(prices))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement