3. Best Time to Buy and Sell Stock
Given an array prices, return the maximum profit you can achieve from one buy and one sell.
範例 1:
輸入: prices = [7,1,5,3,6,4] 輸出: 5
範例 2:
輸入: prices = [7,6,4,3,1] 輸出: 0
限制條件:
1 <= prices.length <= 10^5
Given an array prices, return the maximum profit you can achieve from one buy and one sell.
輸入: prices = [7,1,5,3,6,4] 輸出: 5
輸入: prices = [7,6,4,3,1] 輸出: 0
1 <= prices.length <= 10^5