← Heap / Priority Queue

Pattern Recognition Drill

#115 — Meeting Rooms II

Medium Intervals

The Problem

Given meeting time intervals, find the minimum number of conference rooms required.

What approach would you use?

Think about it before scrolling down.

Key Signals

Heap / Priority Queue

Sort by start. Min-heap of end times. If earliest end <= current start, reuse room. Else add room. O(n log n).

Alt: Sorting

Separate starts and ends into sorted arrays. Sweep with two pointers counting active meetings. O(n log n).

Common Trap

Don't try to simulate rooms directly. The heap tracks the earliest-ending meeting for reuse.

← #114