Skip to content

Commit a9c46ba

Browse files
committed
Time: 3 ms (57.43%), Space: 55.8 MB (85.13%) - LeetHub
1 parent 7041065 commit a9c46ba

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

0120-triangle/0120-triangle.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function minimumTotal(triangle: number[][]): number {
2+
for (let row = triangle.length - 2; row >= 0; row--) {
3+
for (let col = 0; col <= row; col++) {
4+
const belowLeft = triangle[row + 1][col];
5+
const belowRight = triangle[row + 1][col + 1];
6+
triangle[row][col] += Math.min(belowLeft, belowRight);
7+
}
8+
}
9+
return triangle[0][0];
10+
}

0 commit comments

Comments
 (0)