intermediate7 min read·Updated September 20, 2026
Meeting Rooms II (Min Rooms) Explained: Rooms for [[0,30],[5,10],[15,20]]
Master Meeting Rooms II (Min Rooms) with a step-by-step walkthrough of [[0,30],[5,10],[15,20]]. Build a timeline mental model and trace heap allocation.
By Learnisim AI·Published September 20, 2026
LEARNING ARCSetup → Model in the example → Full trace → Twist → Edge cases → Apply
PREREQUISITES
- Basic array sorting
- Min-heap data structure basics
- Interval overlap concepts
Why
Why We Need Meeting Rooms II (Min Rooms) Explained
Phase 1: The Scheduling Bottleneck
Imagine you are managing event spaces and you receive three bookings: Given meetings . The first meeting spans the entire hour and a half from time 0 to 30. Shortly after it begins, a second short meeting kicks off from time 5 to 10, and a third runs from time 15 to 20.
If you blindly assign every incoming booking to a brand-new physical room, you will quickly run out of space. But look closely at the overlap: when the second meeting starts at 5, the first room is still actively occupied by the long meeting. You cannot share that room yet. You need a second room.
However, by the time the third meeting arrives at 15, the second meeting has already finished at 10. Without a smart allocation strategy, it is entirely too easy to waste capacity by keeping doors locked or buying unnecessary real estate. We need a systematic way to track peak concurrency without manually drawing timelines.
Model
The Timeline Mental Model: Overlaps as Concurrent Intersections
Phase 2: Building the Timeline Mental Model
When we look at our meetings [[0,30],[5,10],[15,20]], our goal is to find the peak number of overlapping intervals occurring at any single instant. Imagine dragging a vertical timeline sweep-line from time to . Every time a meeting starts, our room demand increases by one; every time a meeting ends, a room becomes available for reuse.
In our working example, the first meeting starts at and claims a room until . When the second meeting begins at , it cannot use that same room because the first meeting is still active. This forces us to allocate a second room. However, when that second meeting ends at , its room is immediately freed. When the third meeting starts at , it steps into the newly vacated room instead of demanding a third one.
Mapping Starts and Ends
To formalize this model, we separate our interval list into two independent timelines: a list of start times and a list of end times. Sorting these timelines allows us to track resource demand chronologically without getting bogged down in individual meeting pairings. The peak concurrency across these sorted events dictates our minimum room requirement.
Worked example
Tracing [[0,30], [5,10], [15,20]] with Sorted Start and End Arrays
Phase 3: Working Through the Timeline Trace
Now we apply our timeline model to the concrete meetings [[0,30], [5,10], [15,20]]. Instead of checking every minute on a clock, we isolate the critical event timestamps: when meetings begin and when they end.
First, we separate and sort the start times and end times independently:
- Starts:
- Ends:
- Starts:
- Ends:
We use two pointers, for starts and for ends, along with a running room counter and a peak room counter.
Given:
-
-
-
-
starts = -
ends = -
Steps:
1. (): Compare (0) with (10). Since , a new meeting starts before the earliest one finishes. We increment to 1 and advance to 1. becomes .
2. (): Compare (5) with (10). Since , another meeting starts before any room empties. We increment to 2 and advance to 2. becomes .
3. (): Compare (15) with (10). Since , a meeting has finished! We decrement to 1 and advance to 1. stays 2.
1. (): Compare (0) with (10). Since , a new meeting starts before the earliest one finishes. We increment to 1 and advance to 1. becomes .
2. (): Compare (5) with (10). Since , another meeting starts before any room empties. We increment to 2 and advance to 2. becomes .
3. (): Compare (15) with (10). Since , a meeting has finished! We decrement to 1 and advance to 1. stays 2.
Result:
After processing all starts, the maximum rooms active concurrently is 2, matching our expected result for [[0,30], [5,10], [15,20]].
After processing all starts, the maximum rooms active concurrently is 2, matching our expected result for [[0,30], [5,10], [15,20]].
Practice
Practice: Try Tracing a New Meeting Schedule Yourself
Phase 4: Practice
Now that you have seen how the timeline scan tracks concurrent intervals using sorted start and end arrays, it is time to test your mental model. Instead of the original meetings [[0,30], [5,10], [15,20]] which required 2 rooms, let us modify the schedule slightly. Consider the meetings schedule [[0,10], [5,15], [10,20]]. Walk through the start pointer and end pointer technique manually. Keep track of how many rooms are occupied at each time event and determine the peak concurrency.
Apply
Transfer: Recognizing Timeline Interval Patterns in Other Resource Allocation Problems
Phase 5: Apply
The dual-array pointer technique we used for the meetings is not just for physical conference rooms. Whenever you need to track peak concurrent usage across overlapping intervals—whether network connections, CPU thread allocations, or cloud virtual machine instances—the fundamental constraint remains identical: resource demand peaks whenever a new start event occurs before the earliest active end event resolves.
To test this transfer of knowledge, consider a cloud logging service that receives incoming batch jobs instead of meetings. Each job has an arrival timestamp and a completion timestamp, represented as time intervals. If you process incoming jobs with request windows , the exact same sorting logic applies. The start times are and the end times are . By walking through these sorted events just like we did with our conference rooms, you can instantly determine the maximum concurrent worker threads required without simulating every single second of execution.
Whenever you encounter a scheduling bottleneck where intervals overlap, look past the domain-specific nouns. Strip away whether they are people in a room, packets on a wire, or tasks on a queue, and reduce them to their boundary events. Sorting starts independently from ends transforms an naive search into a clean sweep-line traversal.
FAQ
How many rooms are needed for the meeting schedule [[0,30],[5,10],[15,20]]?
2 rooms are needed. The first meeting [0,30] occupies Room 1 the entire time. When [5,10] starts, it requires Room 2. Finally, [15,20] can reuse Room 1 because it starts after [5,10] ends.
Why do we sort start and end times separately in Meeting Rooms II?
Sorting start and end arrays independently allows us to track concurrent active meetings as a timeline sweep, letting us efficiently check if any room has been freed up by the time a new meeting starts.
What is the time complexity of the min-heap approach for Meeting Rooms II?
The time complexity is O(N log N) due to sorting the intervals by start time, and O(N log N) for heap operations as we push and pop meeting end times.
What is a common pitfall when solving Meeting Rooms II?
A common mistake is sorting intervals only by duration or failing to properly check if a room can be reused when a meeting ends at the exact same time another one begins.