Now pop the remaining bars from stack and calculate area with every popped bar as the smallest bar
while ( len ( result ) ) : NEW_LINE INDENT top_val = row [ result . pop ( ) ] NEW_LINE area = top_val * i NEW_LINE if ( len ( result ) ) : NEW_LINE INDENT area = top_val * ( i - result [ - 1 ] - 1 ) NEW_LINE DEDENT max_area = max ( area , max_area ) NEW_LINE DEDENT return max_area NEW_LINE