Stores lIS from tempArr [ ]
List < int > tail = new List < int > ( ) ; tail . Add ( tempArr [ 0 ] ) ; for ( int i = 1 ; i < tempArr . Count ; i ++ ) { if ( tempArr [ i ] > tail [ tail . Count - 1 ] ) tail . Add ( tempArr [ i ] ) ; else if ( tempArr [ i ] < tail [ 0 ] ) tail . Insert ( 0 , tempArr [ i ] ) ; } return ( int ) tail . Count ; }