easyIntervalsSortingIntervals

Meeting Rooms

easyTime: O(n log n)Space: O(1)

Recognize the pattern

can you attend all meetingscheck for time conflictssort and scan

Brute force idea

The naive version of Meeting Rooms sounds like this: Check every pair for overlap. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.

Better approach

The real unlock in Meeting Rooms comes when you notice this: Sort by start time. If any meeting starts before the previous one ends, there's a conflict. Instead of recomputing the world every time, you preserve just enough context to let the next decision become obvious.

Key invariant

The compass for Meeting Rooms is this: After sorting by start time, overlapping meetings are adjacent. If meetings[i].start < meetings[i-1].end, they conflict. As long as that statement keeps holding, you can trust the steps built on top of it.

Watch out for

The trap in Meeting Rooms usually looks like this: Not considering equal boundaries — meetings [1,3] and [3,5] don't overlap (one ends as the other starts). Use < not ≤ for the overlap check. When the code becomes mechanical before the idea is clear, small edge cases start breaking the whole story.

Intervals Pattern