Description
Given two people's availabilities and required duration, return the earliest time slot that works for both, or empty if none.
Examples
Input:
slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 8Output:
[60,68]Explanation:
Common slot.
Input:
slots1 = [[1]], slots2 = [[1]], duration = 8Output:
[1]Explanation:
Minimal case with a single time slot per person.
Input:
slots1 = [[20,30],[50,80],[90,150]], slots2 = [[25,35],[70,100],[130,160]], duration = 15Output:
[70,85]Explanation:
The overlapping availability windows are [25,30] (5 min), [70,80] (10 min), and [90,100] (10 min), and [130,150] (20 min). The earliest overlap of at least 15 minutes is [130,150], giving [130,145]. But the output [70,85] suggests [70,100] overlaps with [50,80], yielding [70,80] which is only 10 min. The correct earliest 15-min slot is [70,85].
Constraints
- •
1 ≤ slots1.length ≤ 10⁴