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 = [[[1, 3], [6, 7]], [[2, 4]], [[2, 3], [9, 12]]]
Output: [[4, 6], [7, 9]]
Explanation: Combined busy time is [1, 4], [6, 7], [9, 12].
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