Staff
Employee Free Time
You are given a schedule representing the working times of multiple employees. Each employee's schedule is a list of non-overlapping busy intervals sorted by start time, and each interval is represented as [start, end].
Return a list of finite intervals representing the common free time for all employees, also as [start, end] intervals, sorted by start time.
A common free-time interval is a time range during which every employee is free. Do not include intervals of length 0, and do not include unbounded intervals before the earliest busy time or after the latest busy time.
Example 1
Input
schedule = [[[1,2],[5,6]],[[1,3]],[[4,10]]]Output
[[3,4]]After merging all busy intervals, the only gap when every employee is free is from 3 to 4.
Example 2
Input
schedule = [[[1,3],[6,7]],[[2,4]],[[2,5],[9,12]]]Output
[[5,6],[7,9]]The merged busy intervals leave common free gaps from 5 to 6 and from 7 to 9.
Constraints
- 1 <= schedule.length <= 50
- 1 <= schedule[i].length <= 50
- 0 <= schedule[i][j][0] < schedule[i][j][1] <= 10^8
- Each employee's intervals are sorted by start time and non-overlapping