|
1 | 1 | # Time: O(m * logn), m is the number of schedule, n is the number of employees, m >= n |
2 | 2 | # Space: O(n) |
3 | 3 |
|
| 4 | +# We are given a list schedule of employees, which represents the working time for each employee. |
| 5 | +# Each employee has a list of non-overlapping Intervals, and these intervals are in sorted order. |
| 6 | +# Return the list of finite intervals representing common, positive-length free time for all employees, also in sorted order. |
| 7 | +# |
| 8 | +# Example 1: |
| 9 | +# Input: schedule = [[[1,2],[5,6]],[[1,3]],[[4,10]]] |
| 10 | +# Output: [[3,4]] |
| 11 | +# Explanation: |
| 12 | +# There are a total of three employees, and all common |
| 13 | +# free time intervals would be [-inf, 1], [3, 4], [10, inf]. |
| 14 | +# We discard any intervals that contain inf as they aren't finite. |
| 15 | +# |
| 16 | +# Example 2: |
| 17 | +# Input: schedule = [[[1,3],[6,7]],[[2,4]],[[2,5],[9,12]]] |
| 18 | +# Output: [[5,6],[7,9]] |
| 19 | +# (Even though we are representing Intervals in the form [x, y], |
| 20 | +# the objects inside are Intervals, not lists or arrays. |
| 21 | +# For example, schedule[0][0].start = 1, schedule[0][0].end = 2, |
| 22 | +# and schedule[0][0][0] is not defined.) |
| 23 | +# |
| 24 | +# Also, we wouldn't include intervals like [5, 5] in our answer, as they have zero length. |
| 25 | +# |
| 26 | +# Note: |
| 27 | +# - schedule and schedule[i] are lists with lengths in range [1, 50]. |
| 28 | +# - 0 <= schedule[i].start < schedule[i].end <= 10^8. |
| 29 | + |
4 | 30 | # Definition for an interval. |
5 | 31 | # class Interval(object): |
6 | 32 | # def __init__(self, s=0, e=0): |
|
0 commit comments