Largest histogram rectangle
Your task
Given the heights of bars in a histogram (each bar has width 1), find the area of the largest axis-aligned rectangle that fits entirely within the histogram. Return that maximum area. Constraints: 0 <= n <= 10^5, 0 <= height[i] <= 10^4.
Examples
largest_rectangle(heights: list[int]) -> intExample 1
Input
largest_rectangle([2, 1, 5, 6, 2, 3])Output
10