The Skyline Problem
Hard · Intervals · about 40 minutes
Asked at Google, Microsoft, Uber, Amazon, Meta.
buildings[i] = [left, right, height] describes a rectangle on flat ground. Return the skyline as a list of key points [x, y] sorted by x: each key point is the left end of a horizontal segment of the outline, and the last point (where the skyline ends) has y = 0. There must be no two consecutive points with the same height.