Search⌘ K
AI Features

Solution: Employee Free Time

Explore how to identify common free time intervals for multiple employees by merging their schedules. Understand the use of a min-heap to process intervals sorted by start times, detect gaps, and efficiently calculate free periods. This lesson helps you develop a clear approach to handling complex interval merging problems often seen in coding interviews.

Statement

You’re given a list containing the schedules of multiple employees. Each person’s schedule is a list of non-overlapping intervals in sorted order. An interval is specified with the start and end time, both being positive integers. Your task is to find the list of finite intervals representing the free time for all the employees.

Note: The common free intervals are calculated between the earliest start time and the latest end time of all meetings across all employees.

Constraints:

  • 11 \leq schedule.length , schedule[i].length 50\leq 50

  • 00 \leq interval.start < interval.end 108\leq 10^8 ...