Meeting Rooms
Decide whether one person can attend all meetings.
Why does this pattern fit?
Restate the exact job
Decide whether one person can attend all meetings.
After sorting by start, only adjacent meetings can reveal an overlap.
O(n log n) time · O(1) extra after sort
Treating a meeting ending exactly when another starts as overlap.
How to solve Meeting Rooms
The goal is to solve this problem from the pattern, not to memorize a finished answer. Use this as a check after your own attempt.
What the question asks
Decide whether one person can attend all meetings.
Why Intervals & sweep line fits
After sorting by start, only adjacent meetings can reveal an overlap.
State to maintain
Sorted intervals and previous end.
Transition
Reject if current start < previous end; otherwise advance.
Time and space
O(n log n) time · O(1) extra after sort
Counterexample to the tempting mistake
Treating a meeting ending exactly when another starts as overlap.
Prove it again tomorrow
Close this page. Rebuild the state and transition from memory, write a test that exposes the mistake above, then solve a fresh input without looking back. A same-day reread is practice, not proof of retention.