Log in
← All problems

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

Examples use JSON: true/false/null are True/False/None in Python.

Run examples checks the examples above. Submit also runs 4 hidden tests.