Skip to main content

Employee Free Time


Given a list of employee intervals representing the start and end times of their availability, find all the intervals of free time that are available for a meeting.

Example 1
schedule: [[[1,2], [5,6]], [[1,3]], [[4,10]]]



all//Employee Free

class Interval:
def __init__(self, start, end):
self.start = start
self.end = end

def employeeFreeTime(schedule):
# sort the schedule
schedule.sort(key=lambda x: x.start)

# find the free time
freeTime = []
end = schedule[0].end
for i in range(1, len(schedule)):
if schedule[i].start > end:
freeTime.append(Interval(end, schedule[i].start))
end = max(end, schedule[i].end)

return freeTime