Build the PrimitiveEasy
Best Time to Buy and Sell Stock
Write `max_profit(prices)` returning the best profit from one buy and one later sell. If no trade is profitable, return `0`.
max_profit([7, 1, 5, 3, 6, 4]) -> 5 (buy at 1, sell at 6)
max_profit([7, 6, 4, 3, 1]) -> 0 (never trade)
Track the cheapest price seen so far and, at every step, the profit you would take selling today. The ordering constraint falls out for free: the minimum is always from a strictly earlier day.
What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.