Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Remove Boxes
Bookmark
Brute Force
Interval DP
Input
Merge trick
All same
Absorb + merge
Alternating
Example (23)
Custom
boxes
=
[1, 2, 1]
boxes =
3
1
0
2
1
1
2
calls: 0
remove a run of same-color boxes for (size)^2 points
boxes =
3
1
0
2
1
1
2
calls: 0
remove a run of same-color boxes for (size)^2 points
boxes =
2
2
0
1
1
calls: 2 depth: 1 best here: 0
run of
1
boxes
pays
1
boxes =
1
1
0
calls: 4 depth: 2 best here: 1
best from these boxes =
1
boxes =
3
1
0
2
1
1
2
calls: 6 depth: 0 best here: 3
run of
1
boxes
pays
1
boxes =
2
1
0
1
1
calls: 8 depth: 1 best here: 4
boxes =
2
1
0
2
1
calls: 9 depth: 1 best here: 0
run of
1
boxes
pays
1
boxes =
1
2
0
calls: 11 depth: 2 best here: 1
best from these boxes =
1
boxes =
3
1
0
2
1
1
2
calls: 13 depth: 0 best here: 5
max points =
5
algo
master
.
io
Step:
Remove runs of equal boxes. A run of k boxes pays k x k. Maximise the total
0 / 108
Input
Merge trick
All same
Absorb + merge
Alternating
Example (23)
Custom
boxes
=
[1, 2, 1]
0 / 108
algo
master
.
io
Step:
Remove runs of equal boxes. A run of k boxes pays k x k. Maximise the total