Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Triangle
Bookmark
Recursion
Memoization
Bottom Up
Input
Example 1
Example 2
Example 3
Custom
triangle
=
[[2],[3,4],[6,5,7],[4,1,8,3]]
rows =
4
2
3
4
6
5
7
4
1
8
3
0
1
2
3
calls: 0
step down to an adjacent cell each row; build cheapest totals bottom-up
rows =
4
2
3
4
6
5
7
4
1
8
3
0
1
2
3
calls: 0
step down to an adjacent cell each row; build cheapest totals bottom-up
rows =
4
2
3
4
6
5
7
4
1
8
3
0
2
3
row = 1
calls: 2
rows =
4
2
3
4
6
5
7
4
4
1
8
3
0
1
3
row = 2
calls: 4
row 2
each cell adds the cheaper of its two children
rows =
4
2
3
4
7
6
5
7
4
4
1
1
8
3
0
1
3
row = 2
calls: 6
rows =
4
2
3
4
7
6
5
7
4
4
1
1
8
3
0
1
2
row = 3
calls: 8
rows =
4
2
9
3
4
7
6
6
5
7
4
4
1
1
8
8
3
0
2
3
row = 1
calls: 9
rows =
4
2
9
3
4
7
6
6
5
7
4
4
1
1
8
8
3
0
1
3
row = 2
calls: 11
row 2
each cell adds the cheaper of its two children
rows =
4
2
9
3
4
7
6
6
5
7
4
4
1
1
8
8
3
0
1
3
row = 2
calls: 13
rows =
4
2
9
3
4
7
6
6
5
7
4
4
1
1
8
8
3
0
1
2
row = 3
calls: 15
rows =
4
answer
11
2
9
3
10
4
7
6
6
5
10
7
4
4
1
1
8
8
3
3
0
1
2
3
calls: 15
min total =
11
= 2 + 3 + 5 + 1
algo
master
.
io
Step:
Walk top to bottom, each step moves to an adjacent cell below. Ask the apex for its cheapest total
0 / 46
Input
Example 1
Example 2
Example 3
Custom
triangle
=
[[2],[3,4],[6,5,7],[4,1,8,3]]
0 / 46
algo
master
.
io
Step:
Walk top to bottom, each step moves to an adjacent cell below. Ask the apex for its cheapest total