Compute the Visible Outline of Overlapping Windows on a Taskbar Strip
Last updated: November 29, 2026
Quick Overview
Given application window bars as (left, right, height) on a one-dimensional strip, return the outline as a list of [x, height] key points where the visible top edge changes height, the classic skyline formulation.
Microsoft
November 29, 20260
0
0 solved
Given application window bars as (left, right, height) on a one-dimensional strip, return the outline as a list of [x, height] key points where the visible top edge changes height, the classic skyline formulation.
A sweep line plus heap Hard problem used in Microsoft onsite loops, here framed as computing the occluded silhouette of overlapping UI layers. The interviewer looks for event sorting, a max-heap of active heights with lazy deletion, and careful handling of equal x coordinates.
What the Interviewer Expects
- Turn each bar into start and end events
- Keep a max-heap of active heights with lazy removal
- Order events so starts at the same x process tallest first
- Emit a key point only when the current max height changes
- Analyze O(n log n)
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 do this with divide and conquer instead of a heap?
- How would you extend this to compute visible area?
- What if bars are added and removed interactively and the outline must update?
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: list of [x, h] sorted by x, where at each x the outline height becomes h, ending with a point at height 0. Consec...
High-Level Design
Collect critical x positions from every left and right edge. Sort bars by left. Sweep the sorted unique x values. At each x, push every bar starting at x onto a max-heap keyed by negative height, stor...