dp ( i , j ) represents the minimum cost for partitioning the array [ 0. . i ] into j groups
let dp = new Array ( n ) ; for ( let i = 0 ; i < dp . length ; i ++ ) { dp [ i ] = new Array ( k + 1 ) ; for ( let j = 0 ; j < ( k + 1 ) ; j ++ ) { dp [ i ] [ j ] = 0 ; } }