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
Coding & Algorithms
Software Engineer
Microsoft
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

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
sweep line
heaps
lazy deletion
skyline
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported