schedules[k] is the list of closed busy intervals [start, end] for person k, sorted and non-overlapping within that person. Return all gaps when nobody is busy, as a sorted list of intervals [a, b] with a < b, where a is the moment the last person became free and b the moment someone becomes busy again. Only gaps between the earliest start and the latest end count. Busy intervals that touch ([1, 3] and [3, 5]) leave no gap.
Examples
Input: schedules = [[[3, 5], [8, 9], [14, 16]], [[1, 4], [10, 12]], [[4, 5]]]
Output: [[5, 8], [9, 10], [12, 14]]
Explanation: Combined busy time is [1, 5], [8, 9], [10, 12], [14, 16].
Input: schedules = [[[1, 5]], [[5, 8]]]
Output: []
Constraints
0 <= len(schedules) <= 100, at most5 * 10**4intervals in total,0 <= start <= end <= 10**9.- Target complexity: O(n log n) where
nis the total number of intervals.
Goals
- Flatten several sorted schedules into one sorted stream
- Track the furthest busy end to detect genuine gaps