Back to DSA
Largest Rectangle in Histogram
hardYou have a histogram described by an array of bar heights (each bar has width 1). Determine the area of the largest axis-aligned rectangle that fits entirely within the histogram.
Examples
Example 1:
Input:
heights = [3,1,6,5,2,4]Output:
10 Example 2:
Input:
heights = [1,3]Output:
3Hints
1234567