data_structures.stacks.largest_rectangle_histogram

Functions

largest_rectangle_area(→ int)

Inputs an array of integers representing the heights of bars,

Module Contents

data_structures.stacks.largest_rectangle_histogram.largest_rectangle_area(heights: list[int]) int

Inputs an array of integers representing the heights of bars, and returns the area of the largest rectangle that can be formed

>>> largest_rectangle_area([2, 1, 5, 6, 2, 3])
10
>>> largest_rectangle_area([2, 4])
4
>>> largest_rectangle_area([6, 2, 5, 4, 5, 1, 6])
12
>>> largest_rectangle_area([1])
1