Driver Code
let a = [ 4 , 5 , 3 , 7 , 8 , 10 , 9 , 8 ] ; let n = a . length ; let k = 4 ; let dp = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { dp [ i ] = new Array ( MAX ) ; for ( let j = 0 ; j < MAX ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } document . write ( recur ( 0 , 0 , 0 , a , n , k , dp ) ) ;