Problem
prices[i] is a stock's price on day i. You may make as many transactions as you like (buy one share, then sell it), with two rules: you can hold at most one share at a time, and after you sell you must wait one day (a one-day cooldown) before buying again. Return the maximum profit.
Example 1
- Input
- prices = [1, 2, 3, 0, 2]
- Output
- 3
- Why
- buy 1, sell 2, cooldown, buy 0, sell 2
Example 2
- Input
- prices = [1]
- Output
- 0
Constraints
1 <= prices.length <= 50000 <= prices[i] <= 1000