Question bank › Monotonic Stack
Dsa Monotonic Stack Warm-up

Building Skyline

You are tasked with visualizing a city skyline represented as a series of buildings with varying heights. Given an array where each element represents the height of a building, write a program to compute the area of the silhouette formed by the skyline. Input format: - The first line contains an integer n (1 <= n <= 50000), the number of buildings. - The second line contains n integers (0 <= heights[i] <= 100), the heights of the buildings. Output format: - A single integer representing the total area of the skyline silhouette. Example: Input: 5 3 5 4 2 1 Output: 15

Key concepts

monotonic_stacklist

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.