The Skyline Problem
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return the skyline formed by these buildings collectively.

30:00

The Skyline Problem
hard
Topics
Companies

A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return the skyline formed by these buildings collectively.

Example 1:
Input: {"buildings":[[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]}
Output: [[2,10],[3,15],[7,12],[12,0],[15,10],[20,8],[24,0]]
Constraints:
  • 1buildings.length1041 \leq \text{buildings.length} \leq 10^4

  • 0lefti<righti23110 \leq \text{left}_i < \text{right}_i \leq 2^{31} - 1

  • 1heighti23111 \leq \text{height}_i \leq 2^{31} - 1

  • buildings is sorted by lefti\text{left}_i in non-decreasing order.

Input
arr ={"buildings":[[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]}

Created 10 events from 5 buildings

Skyline Key Points
Active Heights (Max Heap)

0

Building
Skyline
Sweep Line
Variables
No variables to display
DepthFunction Call
Stack empty
0/13