Solve BestTimeToBuyAndSellStock.