Soal
00:00

3. Best Time to Buy and Sell Stock

MudahArrayAmazonMicrosoft

Given an array prices, return the maximum profit you can achieve from one buy and one sell.

Contoh 1:

Input: prices = [7,1,5,3,6,4]
Output: 5

Contoh 2:

Input: prices = [7,6,4,3,1]
Output: 0

Batasan:

  • 1 <= prices.length <= 10^5
Mode kode inti
● Tersimpan otomatisBaris 1, kolom 1