Initialise [ , ] dp with - 1
let dp = [ ] ; for ( var i = 0 ; i < 2001 ; i ++ ) { dp [ i ] = [ ] ; for ( var j = 0 ; j < 2001 ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } let ans = solve ( A , 0 , Math . floor ( sum / 2 ) , N ) ;