JavaScript program for the above approach
var dp = Array . from ( Array ( 50 ) , ( ) => Array ( 10 ) ) ; for ( var i = 0 ; i < 10 ; i ++ ) for ( var j = 0 ; j < 10 ; j ++ ) dp [ i ] [ j ] = new Array ( 10 ) . fill ( - 1 ) ;