Best Time to Buy and Sell Stock

Try to solve the Best Time to Buy and Sell Stock problem.

Statement