Learn
Practice
Newsletter
Resources
Mobile
New
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Best Time to Buy and Sell Stock II
Bookmark
Input
Input 1
Input 2
Input 3
Custom
prices
=
[7, 1, 5, 3, 6, 4]
7
1
5
3
6
4
0
1
2
3
4
5
trades
0
maxProfit
0
7
1
5
3
6
4
0
1
2
3
4
5
trades
0
maxProfit
0
7
1
5
3
6
4
0
1
2
3
4
5
trades
0
maxProfit
0
7
1
5
3
6
4
i-1
i
0
1
2
3
4
5
trades
0
maxProfit
0
7
1
5
3
6
4
i-1
i
0
1
2
3
4
5
trades
0
maxProfit
0
+4
7
1
5
3
6
4
i-1
i
0
1
2
3
4
5
trades
1
maxProfit
4
7
1
5
3
6
4
i-1
i
0
1
2
3
4
5
trades
1
maxProfit
4
7
1
5
3
6
4
i-1
i
0
1
2
3
4
5
trades
1
maxProfit
4
+3
7
1
5
3
6
4
i-1
i
0
1
2
3
4
5
trades
2
maxProfit
7
7
1
5
3
6
4
i-1
i
0
1
2
3
4
5
trades
2
maxProfit
7
+4
+3
7
1
5
3
6
4
0
1
2
3
4
5
trades
2
maxProfit
7
algo
master
.
io
Step:
Start of algorithm
0 / 12
Input
Input 1
Input 2
Input 3
Custom
prices
=
[7, 1, 5, 3, 6, 4]
0 / 12
algo
master
.
io
Step:
Start of algorithm