Largest Rectangle in Histogram

Given an array of integers representing the heights of bars in a histogram where the width of each bar is 1, return the area of the largest rectangle that can be formed within the bounds of the histogram.

Constraints

  • 1 <= heights.length <= 100000
  • 0 <= heights[i] <= 10000
Saving… · 2 lines
class Solution:
def largestRectangleArea(self, heights: List[int]) -> int:
Console

Click Run to execute sample tests.