Search⌘ K
AI Features

Problem: Largest Rectangle in Histogram

Explore how to determine the largest rectangle area within a histogram by implementing a monotonic stack in Python. Understand the step-by-step approach to track bar indices and efficiently compute the maximum rectangle area in linear time, improving your problem-solving skills with stacks.

Statement

You are given an array of integers heights, where each element represents the height of a bar in a histogram. Every bar has a width of 11.

Determine the area of the largest rectangle that can be formed within the histogram.

Constraints:

  • 11 \leq heights.length 105\leq 10^5

  • ...