Quant Memo
Coding/●●●●

Trading profit with a two-day cooldown

Given daily prices, you may complete unlimited round trips (holding at most one share), but after each sell you must observe a two-day cooldown before buying again.

prices = [1, 4, 0, 0, 0, 5]
-> 8           # buy@1 sell@4, cooldown two days, buy@0 sell@5

Return the maximum profit. Aim for O(n)O(n) time, O(1)O(1) space.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions