Standard Bar Dynamic Programming · DP on Stocks O(n) · O(n)
After every release, the broker's cargo bay must pass a one-hour safety inspection before another lock can open — a mandatory cooldown. Trades remain unlimited otherwise. Dispatch needs the schedule that still maximizes total spread while respecting the forced stand-down hour after each sale.
Input: An array prices where prices[i] is the fee on hour i.
Output: Return the maximum total profit with unlimited transactions and a one-hour cooldown after every sell.
1 <= len(prices) <= 50000 <= prices[i] <= 1000Input: {"prices":[1,2,3,0,2]}
Output: 3
Lock at 1, release at 2, stand down at 0, lock at 0, release at 2 — total 3.
Input: {"prices":[1,2,4]}
Output: 3
A single lock at 1 and release at 4 clears the cooldown for free.