for every j less than i
for ( int j = 0 ; j < i ; j ++ ) { if ( ( arr [ j ] < arr [ i ] ) && ( LIS [ j ] . size ( ) > LIS [ i ] . size ( ) ) ) LIS [ i ] = LIS [ j ] ; } LIS [ i ] . push_back ( arr [ i ] ) ; }