Skip to content

Commit aecf96d

Browse files
authored
Update employee-free-time.py
1 parent e2fbf42 commit aecf96d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Python/employee-free-time.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
# Time: O(m * logn), m is the number of schedule, n is the number of employees, m >= n
22
# Space: O(n)
33

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+
430
# Definition for an interval.
531
# class Interval(object):
632
# def __init__(self, s=0, e=0):

0 commit comments

Comments
 (0)