Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Delete and Earn
Bookmark
Recursion
Memoization
Tabulation
Space Optimized
Hash Map
Input
Example 1
Example 2
Example 3
Two elements
Sequential
Custom
nums
=
[2, 2, 3, 3, 3, 4]
nums
2
2
3
3
3
4
0
0
0
1
0
2
0
3
0
4
points
taking value v earns ALL copies of v, but deletes every v-1 and v+1
nums
2
2
3
3
3
4
0
0
0
1
0
2
0
3
0
4
points
taking value v earns ALL copies of v, but deletes every v-1 and v+1
nums
2
2
3
3
3
4
maxVal =
4
0
0
0
1
2
+2
2
0
3
0
4
points
points[2]
+=
2
→
2
nums
2
2
3
3
3
4
maxVal =
4
0
0
0
1
4
2
0
3
0
4
points
points[3]
+=
3
nums
2
2
3
3
3
4
maxVal =
4
0
0
0
1
4
2
6
+3
3
0
4
points
points[3]
+=
3
→
6
nums
2
2
3
3
3
4
maxVal =
4
0
0
0
1
4
2
9
3
0
4
points
points[4]
+=
4
nums
2
2
3
3
3
4
maxVal =
4
skip
+9
0
0
0
1
4
2
9
3
4
4
points
i
earn
= points[3] + solve(1) =
0
skip
= solve(2) =
0
nums
2
2
3
3
3
4
maxVal =
4
0
0
0
1
4
2
9
3
4
4
points
i
solve(0)
= points[0] =
0
nums
2
2
3
3
3
4
maxVal =
4
skip
+9
0
0
0
1
4
2
9
3
4
4
points
i
solve(3)
= max(
4
,
9
) =
9
nums
2
2
3
3
3
4
maxVal =
4
0
0
0
1
4
2
9
3
4
4
points
i
solve(0)
= points[0] =
0
nums
2
2
3
3
3
4
maxVal =
4
0
0
0
1
4
2
9
+9
3
4
4
points
Max points =
9
algo
master
.
io
Step:
Start: delete values to earn points, nums = [2, 2, 3, 3, 3, 4]
0 / 28
Input
Example 1
Example 2
Example 3
Two elements
Sequential
Custom
nums
=
[2, 2, 3, 3, 3, 4]
0 / 28
algo
master
.
io
Step:
Start: delete values to earn points, nums = [2, 2, 3, 3, 3, 4]