Smallest Time Range Covering an Event From Every Region Log
Last updated: November 29, 2026
Quick Overview
Given k sorted lists of event timestamps, one per data center region, find the smallest inclusive range [a, b] that contains at least one timestamp from every region, breaking ties by the smaller start.
Meta
November 29, 20260
0
0 solved
Given k sorted lists of event timestamps, one per data center region, find the smallest inclusive range [a, b] that contains at least one timestamp from every region, breaking ties by the smaller start.
A Hard merge-and-window problem framed around cross-region incident correlation in Meta infrastructure. The interviewer checks that you move only the pointer at the current minimum, using a heap, and that you know when to stop.
What the Interviewer Expects
- Keeps one pointer per list and a min-heap of the current heads
- Tracks the current maximum among the heads
- Advances only the list holding the current minimum
- Stops as soon as any list is exhausted
- Gives O(N log k) time where N is the total number of timestamps
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
- Solve it by merging all lists into one tagged array and running a sliding window with counts.
- Require at least two events from every region.
- Lists are unbounded streams; can you report the smallest range seen so far?
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: logs, a list of k non-empty lists of integers, each sorted ascending. Output: [a, b] minimizing b - a such that every list has a value in [a, b]; ties go to the smaller a....
High-Level Design
Initially take the first value of every list: that set covers all regions, and its range is from the heap minimum to the current maximum. To possibly shrink the range, the only useful move is to repla...