easyIntervalsSortingIntervals

Meeting Rooms

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

Signals to notice

can you attend all meetingscheck for time conflictssort and scan

Brute force first

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.

The key insight

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.

What must stay true

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.

Easy way to go wrong

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