Driver Code
public static void main ( String [ ] args ) { int a [ ] = { 4 , 5 , 3 , 7 , 8 , 10 , 9 , 8 } ; int n = a . length ; int k = 4 ; int [ ] [ ] dp = new int [ n ] [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } System . out . println ( recur ( 0 , 0 , 0 , a , n , k , dp ) ) ; } }