Largest Rectangle in Histogram
Hard
Arrays
Stack
Monotonic Stack
Find the largest rectangle in a histogram.
Input: space-separated heights
Output: max area
Constraints
See problem-specific constraints. Optimized solution required.
Examples
Example 1:
Input: 2 1 5 6 2 3
Output:
Example 2:
Input: 2 1 5 6 2 3
Output:
Hints
Consider a stack approach.
Think about time complexity.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console