Meeting Rooms
Meeting Rooms is an easy Intervals problem from the Blind 75. The key pattern is sort + adjacent check, and a good solution runs in O(n log n) time.
Problem
Determine whether one person can attend every half-open meeting interval without overlap.
Examples
Example 1
Input
[[0,5],[5,9],[10,12]]Output
trueExample 2
Input
[[0,20],[4,8],[12,16]]Output
falseExample 3
Input
[[8,11],[3,5]]Output
trueApproach
Sort meetings by start; one person can attend all of them unless some meeting starts before the previous one ends.
| Pattern | Sort + adjacent check |
|---|---|
| Time | O(n log n) |
| Space | O(1) beyond sorting |
Watch out for
Intervals are half-open: a meeting may start exactly when another ends.