LAS [ i ] [ pos ] array to find the length of LAS till index i by including or excluding element arr [ i ] on the basis of value of pos
let LAS = new Array ( ) ; for ( let i = 0 ; i < 1000 ; i ++ ) { let temp = new Array ( ) for ( let j = 0 ; j < 2 ; j ++ ) { temp . push ( [ ] ) } LAS . push ( temp ) ; } for ( let i = 0 ; i < 1000 ; i ++ ) { for ( let j = 0 ; j < 2 ; j ++ ) { LAS [ i ] [ j ] = false } } function solve ( arr , n , i , pos ) {