param { number [ ] [ ] } triangle return { number } function minimumTotal ( triangle ) { if ( triangle . length <= 0 || triangle [ 0 ] . length <= 0 ) { return 0 ; } const lens = triangle . length - 1 ; for ( let i = lens - 1 ; i >= 0 ; i -- ) { for ( let j = 0 ; j <= i ; j ++ ) { triangle [ i ] [ j ] = triangle [ i ] [ j ] + Math . min ( triangle [ i + 1 ] [ j ] , triangle [ i + 1 ] [ j + 1 ] ) ; } } return triangle [ 0 ] [ 0 ] ; } export { minimumTotal } ;