Best day to buy and sell
mediumProblem solving20 XP
prices[i] is a share's price on day i. Buy on one day and sell on a later day. Return the biggest profit you can make, or 0 if no trade makes money.
Examples
- Input: prices = [7, 1, 5, 3, 6, 4]Output: 5
- Input: prices = [7, 6, 4, 3, 1]Output: 0
Examples use JSON: true/false/null are True/False/None in Python.