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
static int [ , ] LAS = new int [ 1000 , 2 ] ; static int solve ( int [ ] arr , int n , int i , int pos ) {