HARDasked at 8 companies

The Skyline Problem

A hard-tier problem at 44% community acceptance, tagged with Array, Divide and Conquer, Binary Indexed Tree. Reported in interviews at Yelp and 7 others.

Founder's read

The Skyline Problem is a hard array problem that appears at Google, Goldman Sachs, Citadel, and other major firms. You're given a list of buildings defined by left edge, right edge, and height. Your job is to return the outline of the skyline when all buildings are overlaid. The obvious greedy approach fails. The acceptance rate is 44%, which means most candidates either don't see the trick or implement it wrong under pressure. If this hits your live OA and you blank, StealthCoder surfaces the working solution in seconds, invisible to the proctor.

Companies asking
8
Difficulty
HARD
Acceptance
44%

Companies that ask "The Skyline Problem"

If this hits your live OA

The Skyline Problem is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.

Get StealthCoder
What this means

The trap: you can't just process buildings left to right and pick the max height at each step. Heights merge, overlap, and disappear in non-obvious ways. The solution uses a line sweep combined with a heap or ordered set to track active buildings. You iterate through key x-coordinates (building starts and ends). At each point, you maintain the set of active buildings and emit a skyline point only when the max height actually changes. The heap approach is most common, but it's tricky to remove stale heights efficiently. Divide and conquer and segment tree variants also work but are rarer in interviews. Common failures: forgetting to handle ties (two buildings start at the same x), not detecting when height drops to zero, or using a naive loop that's too slow. StealthCoder handles the edge cases and picks the right data structure before you have to debug under time pressure.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

The Skyline Problem recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.

The Skyline Problem interview FAQ

Do I really need a segment tree or fancy structure?+

No. Heap with lazy deletion or an ordered set (multiset) is standard. Segment tree works but is overkill in most interviews. Heap is simpler to code and usually fast enough. The real trick is tracking when max height changes, not the underlying structure.

Why doesn't greedy left-to-right work?+

Because building heights don't nest cleanly. If building A ends and building B is still active but shorter, you emit a point at A's end but must drop to B's height, not zero. Greedy misses overlaps and merges.

Is this still asked at big tech companies?+

Yes. Google, Goldman Sachs, Citadel, and others report it. It's less frequent than medium array problems but shows up regularly in final-round or senior loops, especially if the company values systems design or optimization.

What's the hardest part to get right?+

Detecting when the max height actually changes. Beginners add points for every event. The real skyline only changes when an active building starts or ends and the max height before and after differs. Proper bookkeeping with a heap or multiset is critical.

Which topic should I focus on first?+

Start with the line sweep and heap approach. It's the most intuitive: iterate x-coordinates, track active heights, emit points when max changes. Divide and Conquer and Segment Tree are optimizations for specific constraints and less likely in a live interview.

Want the actual problem statement? View "The Skyline Problem" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.