Question bank › Monotonic Stack
Dsa Monotonic Stack Medium

Building Heights

You are given an array representing the heights of buildings in a row. For each building, determine how many buildings are to the left that are shorter than the current building. Write a program that computes this. Input Format: - A single line containing space-separated integers representing the heights of buildings. Output Format: - A single line containing space-separated integers representing the counts of shorter buildings to the left for each building. Example: Input: 4 5 2 1 3 6 4 Output: 0 1 0 0 1 5 4

Key concepts

monotonic_stackheight_comparisonbuilding_analysis

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
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.