Best Time to Buy and Sell Stock with Cooldown
Find the maximum profit with a cooldown period of 1 day after selling (cannot buy the next day after selling).
Best Time to Buy and Sell Stock with Cooldown

Find the maximum profit with a cooldown period of 1 day after selling (cannot buy the next day after selling).

Example 1:
Input: [1,2,3,0,2]
Output: 3
Input
arr =[1,2,3,0,2]
1
2
3
0
2
HOLD

(holding stock)

0
SOLD

(just sold)

0
REST

(can buy)

0
State Transitions:
REST --buy--> HOLDHOLD --sell--> SOLDSOLD --cooldown--> REST
Max Profit

0

Initialize state machine

Variables
No variables to display
DepthFunction Call
Stack empty
0/22