Question bank › Monotonic Stack
Dsa Monotonic Stack Easy

Building View Calculation

You are given heights of buildings in a row. For each building, calculate how many buildings can be seen from the current building to the right. A building can be seen if it is taller than all the buildings in between. Input Format: - A single line containing n integers representing the heights of buildings, separated by spaces. Output Format: - A single line containing n integers representing the number of visible buildings from each building, separated by spaces. Example: Input: 3 1 4 2 5 Output: 2 1 1 1 0

Key concepts

monotonic_stackbuildingsview

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.