Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Minimum Falling Path Sum
Bookmark
Recursion
Memoization
2D DP
Space Optimized
Input
Example 1
Example 2
4x3 matrix
Custom
matrix
=
[2,1,3], [6,5,4], [7,8,9]
grid =
3x3
top
land
2
1
3
6
5
4
7
8
9
calls: 0
fall straight down or diagonally; find the cheapest way to the bottom
grid =
3x3
top
land
2
1
3
6
5
4
7
8
9
calls: 0
fall straight down or diagonally; find the cheapest way to the bottom
grid =
3x3
top
land
2
1
3
6
5
4
7
7
8
9
calls: 4
row 2
each cell adds the cheapest of the cells above
grid =
3x3
top
land
2
1
3
13
6
5
4
7
7
8
8
9
calls: 7
row 2
each cell adds the cheapest of the cells above
grid =
3x3
top
land
14
2
1
3
13
6
12
5
4
7
7
8
8
9
9
calls: 10
row 1
each cell adds the cheapest of the cells above
grid =
3x3
top
land
14
2
1
3
13
6
12
5
4
7
7
8
8
9
9
calls: 12
grid =
3x3
top
land
14
2
1
3
13
6
12
5
4
7
7
8
8
9
9
calls: 16
grid =
3x3
top
land
14
2
1
3
13
6
12
5
4
7
7
8
8
9
9
calls: 19
grid =
3x3
top
land
14
2
13
1
3
13
6
12
5
12
4
7
7
8
8
9
9
calls: 22
grid =
3x3
top
land
14
2
13
1
3
13
6
12
5
12
4
7
7
8
8
9
9
calls: 25
grid =
3x3
top
land
14
2
13
1
15
3
13
6
12
5
12
4
7
7
8
8
9
9
calls: 27
min falling path =
13
= 1 + 5 + 7
algo
master
.
io
Step:
Fall from the top row to the bottom, each step moving straight down or one column sideways
0 / 122
Input
Example 1
Example 2
4x3 matrix
Custom
matrix
=
[2,1,3], [6,5,4], [7,8,9]
0 / 122
algo
master
.
io
Step:
Fall from the top row to the bottom, each step moving straight down or one column sideways