Dsa
Monotonic Stack
Medium
Histogram Area
You are given a histogram represented by an array of heights. Write a function that calculates the largest rectangle that can be formed in the histogram.
Input:
- A single line of space-separated integers representing the heights of the histogram bars.
Output:
- A single integer representing the area of the largest rectangle.
Example:
Input: 2 1 5 6 2 3
Output: 10
Key concepts
monotonic_stackarraygeometry
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now