Hard · Intervals
Draw skyline
Given buildings as [left, right, height] triples (left < right, height > 0), return the skyline's key points [x, height] in increasing x: each point is where the outline's height changes, consecutive points have different heights, and the last one drops to 0.
Examples
Example 1
[[2,9,10],[3,7,15],[5,12,12]]Output: (2,10) (3,15) (7,12) (12,0)
Example 2
[[1,5,3],[2,8,4]]Output: (1,3) (2,4) (8,0)
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.