Initialize with maximum value
for ( let i = 0 ; i <= N ; i += 1 ) { dp [ i ] = new Array ( RODS + 1 ) ; for ( let j = 1 ; j <= RODS ; j ++ ) { dp [ i ] [ j ] = new Array ( RODS + 1 ) ; for ( let k = 1 ; k <= RODS ; k += 1 ) { dp [ i ] [ j ] [ k ] = Number . MAX_VALUE ; } } } }