Tap here to switch tabs
Problem
Submissions

Problem: Employee Free Time

hard
40 min
Explore how to determine common free time slots across multiple employee schedules using interval merging techniques. This lesson guides you through analyzing sorted, non-overlapping intervals to find all finite durations when no one is working. You will learn to implement solutions that handle interval objects efficiently, preparing you to tackle similar scheduling problems in coding interviews.

Statement

You are given schedule, a list where each element contains the working hours of one employee.

Each employee’s working hours are represented as a list of Interval objects that are already sorted and do not overlap.

Return all finite intervals with non-zero duration during which all employees are simultaneously free. The resulting list of free intervals should also be sorted in ascending order.

Note: The intervals are represented as objects, not arrays. For example, schedule[0][0].start = 1 and schedule[0][0].end = 2, while schedule[0][0][0] is invalid. Do not include intervals with zero length (for example, [3, 3]) in the output.

Constraints:

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

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

Unlock AI-Powered LearningUpgrade to smarter learning with instant explanations of Ask Agent, Personalized Interview Prep, Real-World Projects, 3 AI Mock Interviews per month, and Personalized Paths
Tap here to switch tabs
Problem
Submissions

Problem: Employee Free Time

hard
40 min
Explore how to determine common free time slots across multiple employee schedules using interval merging techniques. This lesson guides you through analyzing sorted, non-overlapping intervals to find all finite durations when no one is working. You will learn to implement solutions that handle interval objects efficiently, preparing you to tackle similar scheduling problems in coding interviews.

Statement

You are given schedule, a list where each element contains the working hours of one employee.

Each employee’s working hours are represented as a list of Interval objects that are already sorted and do not overlap.

Return all finite intervals with non-zero duration during which all employees are simultaneously free. The resulting list of free intervals should also be sorted in ascending order.

Note: The intervals are represented as objects, not arrays. For example, schedule[0][0].start = 1 and schedule[0][0].end = 2, while schedule[0][0][0] is invalid. Do not include intervals with zero length (for example, [3, 3]) in the output.

Constraints:

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

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

Unlock AI-Powered LearningUpgrade to smarter learning with instant explanations of Ask Agent, Personalized Interview Prep, Real-World Projects, 3 AI Mock Interviews per month, and Personalized Paths