Now pop the remaining bars from stack and calculate area with every popped bar as the smallest bar
while ( result . Count > 0 ) { top_val = row [ result . Peek ( ) ] ; result . Pop ( ) ; area = top_val * i ; if ( result . Count > 0 ) { area = top_val * ( i - result . Peek ( ) - 1 ) ; } max_area = Math . Max ( area , max_area ) ; } return max_area ; }