Code Room
CodingHardcod-g428
Subject Sweep lineLevel Senior–Staff~40 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given a list of buildings, each as [left, right, height] (right > left, height > 0), compute the skyline as a list of key points [x, height] where the height changes, sorted by x. The skyline is the outer contour formed by the silhouette of all buildings; the last key point always has height 0 (ground after the rightmost building). Buildings may overlap. There are up to 10^4 buildings; coordinates and heights fit in 32-bit ints.

Implement
skyline(buildings: list[list[int]]) → list[list[int]]
Examples
in[[[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]]out[[2,10],[3,15],[7,12],[12,0],[15,10],[20,8],[24,0]]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.