Skyline Ridge Builder
Problem Description
You are given a list of buildings, where each building is represented as `[leftEdge, rightEdge, height]`. The buildings are axis-aligned rectangles viewed from the side.
Compute the **skyline** — the outline formed by all buildings when viewed from a distance. The skyline is returned as a list of **key points** `[x, h]` where `x` is the x-coordinate and `h` is the new height starting at `x`. The skyline profile ends with height `0`.
Key points should be listed in increasing order of `x`. Two consecutive key points must not have the same height.
**Example 1:**
```
Input: structures = [[1,4,5],[2,6,4],[7,9,3]]
Output: [[1,5],[4,4],[6,0],[7,3],[9,0]]
```
**Example 2:**
```
Input: structures = [[0,3,8],[1,5,6],[2,4,10]]
Output: [[0,8],[2,10],[4,6],[5,0]]
```
Constraints
- 1 <= structures.length <= 10^4
- 0 <= leftEdge < rightEdge <= 2^31 - 1
- 1 <= height <= 2^31 - 1
- Buildings may overlap
Follow-up
Can you solve this problem using a segment tree or binary indexed tree to support dynamic queries on active heights?
Hints
Try the problem first. If you get stuck, you can reveal hints one at a time.
Solution
Leaderboard
No entries yet for python.
Be the first — submit an accepted solution.