題庫
00:00

3. Best Time to Buy and Sell Stock

簡單陣列AmazonMicrosoft

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
核心程式碼模式
● 已自動儲存第 1 行,第 1 欄