Easy · Sliding window

Best Time to Buy and Sell Stock

Each number is a day’s price. Buy on one day and sell on a later one for the largest profit. Return 0 if there is none.

prices = [7, 1, 5, 3, 6, 4]

→ 5
Record your take

No one has solved it yet.