Medium · End-Time Min Heap
Understand → Visualise → Practice.
Return the minimum rooms needed so every half-open meeting interval can occur.
Sort meetings by start. A min-heap of end times shows the earliest-free room; reuse it if it frees by the new start, otherwise open a new room.
Process meetings in order of start time.
If the earliest end in the heap is ≤ the start, pop it (that room is reused). Push the new meeting's end.
The largest heap size reached is the answer.
O(n log n) time and O(n) space.
Meetings are half-open: one ending at 10 and another starting at 10 can share a room.
Read the full guide first: Heaps and Priority Queues.
Guest mode lets you understand, visualise and run the sample tests. Create a free account to submit and save your solutions.