Now pop the remaining bars from stack and calculate area with every popped bar as the smallest bar
while ( s . Count > 0 ) { tp = s . Peek ( ) ; s . Pop ( ) ; area_with_top = hist [ tp ] * ( s . Count == 0 ? i : i - s . Peek ( ) - 1 ) ; if ( max_area < area_with_top ) { max_area = area_with_top ; } } return max_area ; }