Trading with a minimum holding period
Given daily prices, you may complete unlimited round trips (at most one share), but once you buy you must hold for at least two days before you are allowed to sell. So if you buy on day , the earliest sale is day .
prices = [1, 9, 2, 3]
-> 2 # buy@1 (day 0), the 9 on day 1 is too soon to sell, sell@3 (day 3)
Return the maximum profit. Aim for time, space.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.