Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Maximum Number of Points with Cost
Bookmark
Input
Example 1
Larger Matrix
Equal Values
Single Column
Custom
points
=
[[1,2,3],[1,5,1],[3,1,1]]
grid =
3x3
1
2
3
1
5
1
3
1
1
dp
left
right
pick one cell per row; every column switch costs the distance
algo
master
.
io
Step:
Pick one cell per row. Switching columns between rows costs the distance moved
0 / 26
Input
Example 1
Larger Matrix
Equal Values
Single Column
Custom
points
=
[[1,2,3],[1,5,1],[3,1,1]]
0 / 26
grid =
3x3
1
2
3
1
5
1
3
1
1
dp
left
right
pick one cell per row; every column switch costs the distance
algo
master
.
io
Step:
Pick one cell per row. Switching columns between rows costs the distance moved