← Back to DSA Animator
Meeting Rooms II LC #253 Medium Intervals · Min-Heap
Problem

Given an array of meeting time intervals [[start, end], ...], return the minimum number of conference rooms required.

Example
Input: [[0,30],[5,10],[15,20]]
Output: 2
Explanation: [0,30] uses room 1. [5,10] needs new room (5<30). [15,20] can reuse room 1 (15>10).
Try Examples
Approach
Sort by Start + Min-Heap of End Times
If meeting.start ≥ heap.peek() → room free, poll and reuse. Else → allocate new room. Heap size = rooms in use.
Meeting Schedule
Load an example to begin.
Rooms in use
Variables
Meeting
heap.peek()
Reuse?
Action
Step Logic
Press ▶ Play or Next Step to begin.
Ready
0 / 0
Select an example and press Play.
Algorithm
1
Sort by start time
2
Min-heap stores end times of ongoing meetings
3
If start ≥ peek() → poll (reuse), else new room. Offer(end)
Time
O(n log n)
Space
O(n)
Why Heap

The min-heap tracks when rooms free up. If the earliest-ending meeting ends before the current meeting starts, we reuse that room. Otherwise we need a new room. Heap size = concurrent meetings = rooms needed.