Building skyline outline
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.
0:00 of about 45 min
solution.py
InputExpectedGot
[[[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]][[2,10],[3,15],[7,12],[12,0],[15,10],[20,8],[24,0]]not run yetsample