Create a DP array to memoize result of previous computations
let DP = new Array ( 2 ) ; for ( let i = 0 ; i < 2 ; i ++ ) { DP [ i ] = new Array ( len1 + 1 ) ; for ( let j = 0 ; j < len1 + 1 ; j ++ ) DP [ i ] [ j ] = 0 ; }