Find Common Idle Windows Across Every Warehouse Associate

Last updated: November 29, 2026

Quick Overview

Each warehouse associate has a sorted list of non-overlapping busy intervals for the shift. Return the finite intervals of time when every associate is idle, so a site-wide safety briefing can be scheduled.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Each warehouse associate has a sorted list of non-overlapping busy intervals for the shift. Return the finite intervals of time when every associate is idle, so a site-wide safety briefing can be scheduled.

An Amazon onsite hard question set in fulfillment center shift planning. The interviewer expects you to exploit per-associate sorted lists with a k-way heap merge, find gaps in the union of busy times, and exclude the unbounded time before the first and after the last busy interval.

What the Interviewer Expects
  • Recognize common idle time as gaps in the union of busy intervals
  • Use a min-heap to merge k sorted lists in O(N log k)
  • Track the furthest busy end seen so far
  • Emit a gap when the next start exceeds that end
  • Exclude infinite leading and trailing idle time
Key Topics to Cover
Heap
K-Way Merge
Intervals
Sweep Line
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
  • Find idle windows where at least m of the associates are free.
  • Only return windows of at least 15 minutes.
  • What if schedules are stored on different services and fetched lazily?
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: schedules, a list of k lists, each sorted, non-overlapping [start, end] busy intervals. Output: sorted list of [start, end] intervals with positive length when nobody is busy, between the...

High-Level Design

Everyone is idle exactly where nobody is busy, i.e. the complement of the union of all busy intervals. Since each list is sorted, push the first interval of every associate into a min-heap keyed by st...


Submit Your Answer
Markdown supported