Skip to content
Veltoryx Technologies
ProProblem 4● EasyLeetCode #121 ↗2 min readUpdated 30 October 2026

Best Time to Buy and Sell Stock

Find the biggest profit from one buy and one later sell by tracking the cheapest price seen so far.

01The problem

prices[i] is a stock's price on day i. Buy on one day and sell on a later day. Return the biggest profit, or 0 if no trade makes money.

InputOutputWhy
[7, 1, 5, 3, 6, 4]5buy at 1, sell at 6
[7, 6, 4, 3, 1]0price only falls

Loading the rest of the lesson…