DP array to store the values
let dp = new Array ( n + 1 ) ; for ( let i = 0 ; i < n + 1 ; ++ i ) { dp [ i ] = new Array ( n + 1 ) ; for ( let j = 0 ; j <= n ; ++ j ) { dp [ i ] [ j ] = new Array ( n + 1 ) ; for ( let k = 0 ; k <= n ; ++ k ) { dp [ i ] [ j ] [ k ] = - 1 ; } } } sweet [ 0 ] = 0 ;