FAANG · LeetCode #759
Employee Free Time — three-stage drill
1The ProblemHard
Employee Free Time
Time windows when EVERY employee is free at the same time.
Examples
[[[1,3],[6,8]],[[2,4],[7,11]],[[9,12]]]→ [[4,6]][[[1,2],[5,6]],[[1,3]],[[4,10]]]→ [[3,4]]
constraintEach employee's blocks are already sorted and non-overlapping; output free intervals must have positive length.
2The PatternTIME O(n log n) · SPACE O(n)
Intervals
Given a pile of ranges, sort them by start — now any overlap is a neighbour, so a single left→right pass handles them.
Problems using this pattern
3The SolutionRESULT → [[4,6]]
Step through it
given: 3 employees' schedules · find times when EVERYONE is free
Step 1 / 8
Arrow keys to navigate · escape to reset