Skip to content
Decoder

Employee Free Time

Hard

Problem

schedule[i] is the list of working intervals [start, end] for employee i, sorted and non-overlapping. Return the common free time: every stretch of positive length when no employee is working, between the first time anyone starts and the last time anyone finishes. Return the free intervals sorted.

Example 1

schedule = [[[1, 2], [5, 6]], [[1, 3]], [[4, 10]]]

Example 2

  →  [[3, 4]]

Example 3

schedule = [[[1, 3], [6, 7]], [[2, 4]], [[2, 5], [9, 12]]]

Example 4

  →  [[5, 6], [7, 9]]

Intervals that touch, like [1, 2] and [2, 3], leave no free time between them.

Constraints

  • 1 <= schedule.length, schedule[i].length <= 50
  • 0 <= start < end <= 10^8

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.