Loop to compute the smaller elements at the left
for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] ) { dpLeft [ i ] = dpLeft [ i - 1 ] + 1 ; } else { dpLeft [ i ] = 1 ; } } int dpRight [ n ] ; dpRight [ n - 1 ] = 1 ;