Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Max Chunks To Make Sorted
Bookmark
Brute Force
Sum Check
Running Max
Input
Input 1
Input 2
Input 3
Custom
arr
=
[4, 3, 2, 1, 0]
chunks =
0
4
0
3
1
2
2
1
3
0
4
chunks =
0
4
0
3
1
2
2
1
3
0
4
chunks =
0
4
0
3
1
2
2
1
3
0
4
chunks =
0
4
0
3
1
2
2
1
3
0
4
no match yet — the current chunk must extend further
chunks =
0
4
0
3
1
2
2
1
3
0
4
sorted prefix
3
4
target [0..i]
0
1
chunks =
0
4
0
3
1
2
2
1
3
0
4
no match yet — the current chunk must extend further
chunks =
0
4
0
3
1
2
2
1
3
0
4
no match yet — the current chunk must extend further
chunks =
0
4
0
3
1
2
2
1
3
0
4
sorted prefix
1
2
3
4
target [0..i]
0
1
2
3
chunks =
0
4
0
3
1
2
2
1
3
0
4
no match yet — the current chunk must extend further
chunks =
1
4
0
3
1
2
2
1
3
0
4
match!
close chunk [5..4], chunks = 1
chunks =
1
4
0
3
1
2
2
1
3
0
4
max chunks =
1
algo
master
.
io
Step:
Brute force: a chunk closes at i when sorting arr[0..i] gives [0..i].
0 / 12
Input
Input 1
Input 2
Input 3
Custom
arr
=
[4, 3, 2, 1, 0]
0 / 12
algo
master
.
io
Step:
Brute force: a chunk closes at i when sorting arr[0..i] gives [0..i].