Dsa
Monotonic Stack
Hard
Build a Histogram of Heights
You are given a list of heights represented as integers. Your task is to compute the area of the largest rectangle that can be formed in a histogram built from these heights. Write a program to calculate this largest rectangle area.
Input Format:
- A single line containing space-separated integers representing the heights of the histogram bars.
Output Format:
- An integer representing the area of the largest rectangle that can be formed.
Example:
Input:
2 1 5 6 2 3
Output:
10
Key concepts
monotonic_stackhistogramarea_calculation
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