Maximum Area Rectangle in Histogram

Question: Find the maximum rectangle (in terms of area) under a histogram in linear time. I mean the area of largest rectangle that fits entirely in the Histogram. (Please refer figures before code section for clarity. If I include bar i completely, those figure will tell how much maximum area rectangle I can get.) Consider the histogram below: Max area of the rectangle: Max area = 4 * 3 = 12 [Read More]