Driver code
var arr = [ 1 , 2 , 3 , 4 , 6 ] ; var n = arr . length ; var M = 4 ; var dp = Array ( n + 1 ) . fill ( - 1 ) . map ( x => Array ( MAX ) . fill ( - 1 ) ) ; res = isPossible ( n , 0 , 0 , M , arr , dp ) ; document . write ( ( res ? " " : " " ) ) ;