JavaScript Solution in DP


  • 0
    S
    var minimumTotal = function(triangle) {
        'use strict';
        for (let i = triangle.length - 2; i >= 0; i--) {
            for (let j = 0; j <= i; j++) {
                triangle[i][j] += Math.min(triangle[i + 1][j], triangle[i + 1][j + 1]);
            }
        }
        return triangle[0][0];
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.