Variable to store states of dp
let dp = new Array ( arrSize ) ; let visit = new Array ( arrSize ) ; for ( let i = 0 ; i < arrSize ; i ++ ) { dp [ i ] = new Array ( maxSum ) ; visit [ i ] = new Array ( maxSum ) ; for ( let j = 0 ; j < maxSum ; j ++ ) { dp [ i ] [ j ] = 0 ; visit [ i ] [ j ] = 0 ; } }