Trading With Cooldown
prices[i] is a stock's price on day i. You may complete as many buy-sell transactions as you like, holding at most one share, but after selling you must wait one day before buying again. Return the maximum profit.
Examples
EXAMPLE WALKTHROUGHclassic
A guided view of the published example, not a trace of your code.
INPUT
[[1,2,3,0,2]]TASKtrading_with_cooldown()
EXPECTED OUTPUT
3Start with the input values shown in this example.
Example 1 of 3
Input: prices = [1,2,3,0,2]
Output: 3
Explanation: classic
Input: prices = [1]
Output: 0
Explanation: single day
Input: prices = [5,4,3]
Output: 0
Explanation: falling
Hint 1
Track three states per day: holding, just sold, and resting (free to buy).