Arrays and Stacks lessons
Node 22.08.0
Loading editor…
Test casesRun to compare output
Inputprices = [7,1,5,3,6,4]
Expected5
Output—
Buy on day 1 (price = 1) and sell on day 4 (price = 6), profit = 6 - 1 = 5.
More practice
Same technique, different problems. Try them without the walkthrough.