Dsa
Monotonic Stack
Easy
Max Rectangle in Histogram
Given an array representing the histogram's bar heights, compute the area of the largest rectangle that can be formed under the histogram.
Input:
- The first line contains an integer n (1 <= n <= 10000), the number of bars in the histogram.
- The second line contains n integers representing the heights of the bars (0 <= height <= 10000).
Output:
- A single integer representing the maximum rectangle area.
Example:
Input:
5
2 1 5 6 2
Output:
10
Key concepts
monotonic_stackhistogrammax_rectangle
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