Dashboard
LC #84
Largest Rectangle in Histogram
Pattern · ?GoogleAmazonMetaBloomberg
Problem
Find the area of the largest rectangle that can be formed in a histogram.
Constraints
- 1 ≤ n ≤ 10⁵
- 0 ≤ heights[i] ≤ 10⁴
Example
- Input
- heights = [2, 1, 5, 6, 2, 3]
- Output
- 10
- Why
- Largest rectangle uses bars at index 2 and 3 (heights 5,6): width=2, height=5 → area=10
Spot the pattern
Which pattern cracks it?
Hints
One at a time