If this bar is lower than top of stack , then calculate area of rectangle with stack top as the smallest ( or minimum height ) bar . ' i ' is ' right ▁ index ' for the top and element before top in stack is ' left ▁ index '
top_val = row [ result . top ( ) ] ; result . pop ( ) ; area = top_val * i ; if ( ! result . empty ( ) ) area = top_val * ( i - result . top ( ) - 1 ) ; max_area = max ( area , max_area ) ; } }