Meeting Rooms II
Problem Statement
You get a list of meetings. Meeting i runs from intervals[i][0] to intervals[i][1].
Every meeting needs its own room while it is running. Return the smallest number of rooms that can hold all the meetings.
A meeting is over at its end time, so a room freed at 10 can be used by a meeting starting at 10.
A list intervals of [start, end] pairs.
One integer: the minimum number of rooms needed.
[0,30] needs a room the whole time. [5,10] and [15,20] don't overlap each other, so they can share a second room.
The meetings never overlap, so one room is enough.
At time 5, meetings [4,9], [2,6] and [5,8] are all running. [1,4] ended at 4, so its room went to [4,9].
- • 1 ≤ intervals.length ≤ 10^4
- • 0 ≤ start < end ≤ 10^6
Pattern Recognition Clues
Recognising these key signals in the problem description immediately identifies the pattern:
Approach Complexity Ladder
For each meeting's start, count how many meetings are running at that moment
Assign rooms in start order; a min-heap tells you the room that frees up first
Two sorted lists of times; running = started − ended at each start
The rooms needed equals the most meetings running at once. The count only rises when a meeting starts, so the busiest moment is some start time. For each meeting i, count the meetings j with start_j ≤ start_i < end_j. Return the biggest count.
Recognition rule for this sub-pattern:
Unlock Complete Visual Walkthrough & Optimal C++
The interactive animated dry-run player, optimized C++ implementation, state invariant derivations, and edge-case breakdown for this question are part of Brute2Best Pro. The anchor question of every sub-pattern is completely free.
First anchor question per pattern, Part 1 LLD & Module 1 C++ basics are 100% Free forever.
How this concept connects to System Design & C++ Systems
Top engineering interviews test whether you understand how algorithms like Intervals translate into production architectures and low-level memory mechanics.
Foundations: Object-Oriented Principles in C++23
Class invariants, pure virtual interfaces, and RAII smart pointers.
Food Delivery System (Zomato Architecture)
Real-world machine coding application of algorithms and design patterns.
Pointers vs References Deep Dive
Pointer arithmetic and memory layout under the hood.
Virtual Method Table (vtable) & Memory Layout
Polymorphism, vptr overhead, and multiple inheritance in memory.