84. Largest Rectangle in Histogram
84. Largest Rectangle in Histogram
Description
Given an array of integers heights
representing the histogram’s bar height where the width of each bar is 1
, return the area of the largest rectangle in the histogram.
Example 1:
![](https://assets.leetcode.com/uploads/2021/01/04/histogram.jpg)
1 | Input: heights = [2,1,5,6,2,3] |
Example 2:
![](https://assets.leetcode.com/uploads/2021/01/04/histogram-1.jpg)
1 | Input: heights = [2,4] |
Constraints:
1 <= heights.length <= 10^5
0 <= heights[i] <= 10^4
Hints/Notes
- 2024/12/25
- monotonic stack
- 0x3F’s solution(checked)
Solution
Language: C++
1 | class Solution { |