Tightest Time Window Containing a GPS Ping From Every Driver

Last updated: November 29, 2026

Quick Overview

Each of k drivers has a sorted list of GPS ping timestamps; find the shortest time window [lo, hi] that contains at least one ping from every driver, returning the earliest such window on ties.

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

0

0

0 solved


Each of k drivers has a sorted list of GPS ping timestamps; find the shortest time window [lo, hi] that contains at least one ping from every driver, returning the earliest such window on ties.

Uber's safety and mapping teams sometimes need a moment when a whole group of drivers (for example, a convoy or an event fleet) reported positions close together in time for a consistent snapshot. The onsite checks that you merge the k sorted lists and run a sliding window over the merged stream, or equivalently keep a heap of one pointer per driver.

What the Interviewer Expects
  • Reframe as smallest range covering at least one element from each of k lists
  • Either merge all pings with driver labels, or keep a heap with one pointer per driver
  • Slide a window and track how many drivers are covered
  • Shrink from the left while coverage holds
  • Analyze O(N log k) or O(N log N)
Key Topics to Cover
sliding window
k-way merge
heap
smallest range
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 only m of the k drivers need to be covered?
  • How would you do this over a live stream of pings?
  • Compare the heap-of-pointers approach with merge-then-slide in memory use
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: pings, a list of k non-empty sorted lists of integers.
  • Output: [lo, hi] minimizing hi - lo such that every driver has a ping in [lo, hi]; earliest lo on ties....
High-Level Design

Tag each ping with its driver and merge into one sorted stream (heap merge, O(N log k)). Now run the classic covering window: extend right, incrementing the count for that driver; when a driver's co...


Submit Your Answer
Markdown supported