iterate through array and find end index of LIS and its Size
for ( int i = 1 ; i < n ; i ++ ) { if ( hash . ContainsKey ( A [ i ] - 1 ) ) { var val = hash [ A [ i ] - 1 ] ; hash . Remove ( A [ i ] ) ; hash . Add ( A [ i ] , val + 1 ) ; } else { hash . Add ( A [ i ] , 1 ) ; } if ( LIS_size < hash [ A [ i ] ] ) { LIS_size = hash [ A [ i ] ] ; LIS_index = A [ i ] ; } }