LeetCode 253 ·
Medium
Meeting Rooms II
Find the minimum number of rooms needed to host all meetings.
Try it
Step through the core mechanic. The simulator below runs the greedy shape this problem is built on.
Walk the pattern
No dedicated step-through for this one yet. The shape is Greedy — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.
The approach
Sweep line: sort start and end times; scan in time order, +1 room on a start, −1 on an end, tracking the peak. Equivalent: a min-heap of end times, sized to the maximum overlap.
| Aspect | Value |
|---|---|
| Pattern | Greedy |
| Recognise it by | Max concurrent intervals — minimum rooms. |
| Time complexity | O(n log n) |
| Space complexity | O(n) |
| Difficulty | Medium |
Who asks it
Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.