Solve BestTimeToBuyAndSellStock in O(n)