Common Free Windows Across Every Courier's Busy Schedule

Last updated: November 29, 2026

Quick Overview

Given each courier's sorted list of non-overlapping busy intervals, return the finite time windows during which every courier is free, which is when a team-wide training session or app update could be pushed.

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

0

0

0 solved


Given each courier's sorted list of non-overlapping busy intervals, return the finite time windows during which every courier is free, which is when a team-wide training session or app update could be pushed.

Uber Eats operations sometimes need moments when no courier on a team is mid-delivery. The onsite interviewer expects you to treat this as merging many sorted lists, either by flattening and sorting or with a heap to exploit per-courier ordering, and to discuss the trade-off.

What the Interviewer Expects
  • Reframe common free time as gaps in the union of all busy intervals
  • Exploit per-courier sorted order with a k-way heap merge
  • Merge on the fly and emit gaps with positive length
  • Exclude unbounded windows before the first and after the last busy interval
  • Compare O(N log N) flatten-and-sort with O(N log k) heap merge
Key Topics to Cover
k-way merge
heap
interval union
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
  • What if you only need windows where at least m of the k couriers are free?
  • How would you return only windows of at least 15 minutes?
  • How would you handle schedules that update in real time?
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 inner list holds sorted, non-overlapping [start, end) intervals.
  • Output: sorted list of [a, b) with a < b where nobody is busy, between the earlie...
High-Level Design

Everyone is free exactly in the gaps of the union of all busy intervals. Flattening and sorting all N intervals works in O(N log N). Since each courier's list is sorted, a min-heap seeded with each co...


Submit Your Answer
Markdown supported