Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Max Profit Finder

Write a function get_max_profit that takes an array of stock prices ordered sequentially by day and returns the max profit you could earn by buying and selling at the optimal time. You never want to lose money, so if there is no max profit, return 0.

For example, if you have the following stock prices:

stock_prices = [10, 7, 5, 8, 11, 9]

You should return 6, because you could buy at 5 and sell at 11.