Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Best Time to Buy and Sell Stock with Cooldown
Bookmark
Input
Standard
Single day
Longer
Small
Custom
prices
=
[1, 2, 3, 0, 2]
prices
held
holding a stock
sold
just sold today
rest
idle / cooldown
track 3 states per day, you can only buy from rest, and selling forces a cooldown
algo
master
.
io
Step:
Start: stock prices = [1, 2, 3, 0, 2], one buy/sell at a time with a 1-day cooldown after selling
0 / 18
Input
Standard
Single day
Longer
Small
Custom
prices
=
[1, 2, 3, 0, 2]
0 / 18
prices
held
holding a stock
sold
just sold today
rest
idle / cooldown
track 3 states per day, you can only buy from rest, and selling forces a cooldown
algo
master
.
io
Step:
Start: stock prices = [1, 2, 3, 0, 2], one buy/sell at a time with a 1-day cooldown after selling