118. Largest Rectangle in a Histogram
HardStacks
heights gives the heights of adjacent bars, each 1 unit wide. Return the area of the largest rectangle that fits entirely inside the histogram.
Example 1
Input: heights = [2, 1, 5, 6, 2, 3] Output: 10 Explanation: Bars of height 5 and 6 give a 5 × 2 rectangle.
Constraints
1 ≤ heights.length ≤ 10⁵0 ≤ heights[i] ≤ 10⁴