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