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

Question

Given a list of buildings, each [left, right, height] with positive height, compute the skyline outline as a list of key points [x, height]. A key point is the left endpoint of a horizontal segment of the outline; consecutive points must not have equal heights, and the rightmost point of every skyline ends at ground level (height 0). Buildings are given sorted by left edge. Return the list of key points sorted by x.

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.