Largest Rectangle In Histogram
Return the greatest rectangular area supported by consecutive unit-width histogram bars.
Example 1
heights = [3,1,3,3]6Explanation
The final two height-three bars support area 6, exceeding the width-four height-one rectangle.
Example 2
heights = [2,2,2]6Explanation
All three bars support height 2 across width 3, giving 6.
Example 3
heights = [0]0Explanation
A zero-height bar supports area zero.
Constraints
- 1 <= len(heights) <= 100000
- Heights are 0..10000
Function contract
largestRectangleAreaArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 34 cases, on your device.
[3,1,3,3]