Compute the Visible Outline of Overlapping Event Banners
Last updated: November 29, 2026
Quick Overview
Each promotional banner on a timeline is a rectangle (left, right, height) resting on a common baseline. Return the outline as a list of [x, height] key points where the visible top edge changes height.
Meta
November 29, 20260
0
0 solved
Each promotional banner on a timeline is a rectangle (left, right, height) resting on a common baseline. Return the outline as a list of [x, height] key points where the visible top edge changes height.
This is the skyline problem in Meta's onsite style, framed as rendering the combined top edge of stacked event banners in a Facebook Events timeline. The interviewer checks that you can run a sweep line with a max-heap, handle ties at shared x coordinates, and avoid emitting redundant points.
What the Interviewer Expects
- Converts rectangles into start and end events sorted by x
- Uses a max-heap of active heights with lazy deletion
- Handles several events at the same x before emitting a point
- Emits a key point only when the max height actually changes
- Explains O(n log n) complexity
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you compute the total visible area under the outline?
- Could a segment tree replace the heap, and when would you choose it?
- How would you merge two outlines computed in parallel?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of (left, right, height) with left < right and height > 0. Output: key points [x, h] sorted by x, where h is the outline height starting at x; the last point drops to 0. Consecutive po...
High-Level Design
Sweep x from left to right over all distinct edge coordinates. Keep a max-heap of (-height, right) for banners that have started. At each x, push every banner whose left equals x, then pop from the ...