Question bank › Monotonic Stack
Dsa Monotonic Stack Hard

Building View Optimization

Given an array of building heights in a city aligned along a street, determine how many buildings can be seen from an observer standing at the leftmost end of the street. A building can only be seen if it is taller than any building that has been seen before it. Print the count of visible buildings. Example: Input: 4 2 3 1 5 Output: 3 Input format: A single line containing space-separated integers representing building heights. Output format: An integer representing the count of visible buildings from the left.

Key concepts

monotonic_stackbuildings

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