driver function
let arr = [ 1 , 3 , 1 , 5 , 2 ] ; let n = arr . length ; let dp = new Array ( MAX ) ; for ( var i = 0 ; i < dp . length ; i ++ ) { dp [ i ] = new Array ( 2 ) ; } for ( var i = 0 ; i < dp . length ; i ++ ) { for ( var j = 0 ; j < dp . length ; j ++ ) { dp [ i ] [ j ] = 0 ; } } document . write ( solve ( dp , arr , 0 , n - 1 , 1 ) ) ;