The Skyline Problem
Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks most first attempts at The Skyline Problem is emitting a point for every building edge instead of every height change. Google reported this one in December 2025, and the constraints (up to 100000 buildings, coordinates up to a billion) rule out anything quadratic or coordinate-by-coordinate. It's a sweep line with a max-heap. If your head goes blank on the ordering rules at x ties, StealthCoder is the invisible safety net on the live OA. Know the shape of the solution before you open the assessment.
The problem
Each building is represented by [left, right, height] and covers the half-open horizontal interval [left, right). The skyline is the outer contour formed by the union of all buildings. Return its critical points as rows [x, height] in increasing x order. A critical point records every x coordinate where the visible maximum height changes. Do not return adjacent points with equal heights, and include the final point where the skyline returns to height 0. Return an empty matrix when there are no buildings. Function getSkyline(buildings: int[][]) → int[][] Examples Example 1 buildings = [[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]] return = [[2,10],[3,15],[7,12],[12,0],[15,10],[20,8],[24,0]] The tallest active building changes at x coordinates 2, 3, 7, 12, 15, 20, and 24. Example 2 buildings = [[0,2,3],[2,5,3]] return = [[0,3],[5,0]] The touching buildings have equal height, so x = 2 does not change the skyline and is not a critical point. Constraints 0 <= buildings.length <= 100000 Every building is [left, right, height] with 0 <= left < right <= 1000000000 and 1 <= height <= 1000000000. Buildings may overlap, touch, or repeat, and the input need not be sorted.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Turn each building into two events: a start at left with its height, and an end at right. Sort by x. Sweep left to right, keep a max-heap of active heights seeded with 0, and after processing all events at one x, compare the heap top to the previous max. If it differs, emit [x, top]. The pitfalls are all in ties. Process every event at the same x before recording a point, or you'll emit bogus points between touching buildings, like Example 2 where x = 2 must vanish. Removal is lazy: pop the top only while it's expired, using the end x. Skip points whose height equals the last emitted height. Complexity is O(n log n). If the tie handling slips under time pressure, StealthCoder can surface a working version on the live OA.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill The Skyline Problem cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as the skyline problem. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Google's OA.
Google reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
The Skyline Problem FAQ
What's the trick to The Skyline Problem?+
Sweep line plus a max-heap of active building heights. Break buildings into start and end events, sort by x, and emit a point only when the heap's max changes. Everything else is tie handling and not emitting duplicate heights.
How hard is this really for a Google OA?+
It's a hard problem, mostly because of edge cases rather than a deep idea. If you've seen sweep line with a heap, it's about 30 lines. If you haven't, the tie rules at equal x will eat your time.
Why does Example 2 return only two points?+
The buildings [0,2,3] and [2,5,3] touch at x = 2 with the same height 3. The visible max never changes there, so no critical point exists. You get [0,3] and the final drop [5,0].
How do I handle removing buildings from the heap?+
Use lazy deletion. Store (height, right) pairs in the heap. At each x, pop the top while its right is less than or equal to x. You never need to remove from the middle, which keeps it O(n log n).
How do I prepare for this in 48 hours?+
Write the sweep line solution from scratch twice, then test it on touching buildings, identical buildings, nested buildings, and empty input. Those four cases catch nearly every bug. Also confirm the final point returns to height 0.