Solution: Employee Free Time

Let's solve the Employee Free Time problem using the Merge Intervals pattern.

Statement

You’re given a list containing the schedules of multiple employees. Each person’s schedule is a list of non-overlapping intervals in a 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.

Constraints:

  • 1≤1 \leq schedule.length , schedule[i].length ≤50\leq 50

  • 0≤0 \leq interval.start < interval.end ≤108\leq 10^8, where interval is any interval in the list of schedules.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.