Given stock prices, return the maximum profit you can achieve with as many transactions as you like, but after selling a stock you must wait one day before buying again. This is a standard recurrence-based DP with multiple states.
prices = stock prices by day
maximum profit with 1-day cooldown after selling
Example 1:
Input:
prices = [1,2,3,0,2]
Output:
3
Explanation:
Buy on day 1, sell on day 3, cooldown on day 4, buy on day 4, sell on day 5.
Example 2:
Input:
prices = [1]
Output:
0
Explanation:
There is no opportunity to sell.