Driver Code
let k = 0 ; let arr1 = [ 1 , 2 , 3 , 4 , 5 ] ; let arr2 = [ 5 , 3 , 1 , 4 , 2 ] ; let n = arr1 . length ; let m = arr2 . length ; let dp = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) for ( let j = 0 ; j < MAX ; j ++ ) for ( let l = 0 ; l < MAX ; l ++ ) dp = - 1 ; document . write ( lcs ( dp , arr1 , n , arr2 , m , k ) ) ;