Meeting Rooms

Can a person attend all meetings?

Pattern

Sort + Overlap Check

This problem follows the Sort + Overlap Check pattern, commonly found in the Intervals category. Recognizing this pattern is key to solving it efficiently in an interview setting.

Approach

How to Solve It

Sort by start time. Check if any meeting starts before the previous ends.

Key Insight

Sorting by start time means you only need to check adjacent intervals — if interval i overlaps with i-1, you can't attend both.

Step-by-step

  1. 1Sort meetings by start time
  2. 2Check if any meeting starts before the previous one ends
  3. 3If overlap found, return false
  4. 4If no overlaps, return true

Pseudocode

intervals.sort(key=lambda x: x[0])
for i in range(1, len(intervals)):
    if intervals[i][0] < intervals[i-1][1]:
        return false
return true
Complexity Analysis

Time Complexity

O(n log n)

Space Complexity

O(1)
More Intervals Problems

Master this pattern with YeetCode

Practice Meeting Rooms and similar Intervals problems with flashcards. Build pattern recognition through active recall.

Practice this problem