Stores lIS from tempArr [ ]
let tail = [ ] ; tail . push ( tempArr [ 0 ] ) ; for ( let i = 1 ; i < tempArr . length ; i ++ ) { if ( tempArr [ i ] > tail [ tail . length - 1 ] ) tail . push ( tempArr [ i ] ) ; else if ( tempArr [ i ] < tail [ 0 ] ) tail . unshift ( 0 , tempArr [ i ] ) ; } return tail . length ; }