Problem
FAANG · LeetCode #252

Meeting Rooms — three-stage drill

1The ProblemEasy

Meeting Rooms

Can one person attend every meeting? — any overlap means no.

can one person attend every meeting? (any two overlap → no)meetings[0,5)[5,10)[8,12)[13,16)024681012141618[5,10) and [8,12) share the slot 8–10 → can't attend bothreturnfalse
Examples
[[0,30],[5,10],[15,20]]→ false[[7,10],[2,4]]→ true

constraintMeetings are half-open intervals [start, end); a meeting ending at t and another starting at t do NOT overlap.

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.

sort the ranges by start, then sweep once01234567891011[7,9][2,5][1,3][8,10]given: a pile of ranges in any order
Problems using this pattern
3The SolutionRESULT → true

Step through it

given — meetings in arrival ordermeetingsB [5,10)A [0,5)C [10,15)024681012141618
given: 3 meetings · can one person attend all of them?
Step 1 / 5
Arrow keys to navigate · escape to reset

All problems by pattern

Backtracking

Recursive Descent