Question
Given daily prices, compute the maximum profit obtainable by buying once and selling once later. You may choose not to trade, in which case the profit is `0`. ```python def max_profit(prices: list[int]) -> int: ... ``` Prices are non-negative integers. An empty or one-day input returns `0`. Solve the problem in `O(n)` time and `O(1)` auxiliary space. ## Staged follow-ups 1. Allow any number of non-overlapping transactions while holding at most one share. 2. Add a fixed transaction fee or a one-day cooldown after selling. 3. Return the chosen buy and sell days with deterministic tie-breaking.