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

Question

Given a list of buildings, each [left, right, height], compute the skyline as a list of key points [x, height], where each key point is the left endpoint of a horizontal segment of the outline (in left-to-right order). The last key point always has height 0, marking the ground at the rightmost edge. Consecutive segments must differ in height. Coordinates are integers; buildings may overlap arbitrarily.

Implement
get_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.