Loop to compute the smaller elements at the left
for i in range ( n ) : NEW_LINE INDENT if arr [ i ] > arr [ i - 1 ] : NEW_LINE INDENT dpLeft [ i ] = dpLeft [ i - 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT dpLeft [ i ] = 1 NEW_LINE DEDENT DEDENT dpRight = [ 0 ] * n NEW_LINE dpRight [ - 1 ] = 1 NEW_LINE