25. Meeting Rooms II
mediumAsked at RobloxFind the minimum number of rooms needed to hold all meetings without overlap — Roblox applies the same interval-scheduling logic to allocate game servers and physics simulation slots across concurrent player sessions.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Problem
Given an array of meeting time intervals where intervals[i] = [start_i, end_i], return the minimum number of conference rooms required to hold all meetings.
Constraints
1 <= intervals.length <= 10^40 <= start_i < end_i <= 10^6
Examples
Example 1
intervals = [[0,30],[5,10],[15,20]]2Example 2
intervals = [[7,10],[2,4]]1Approaches
1. Brute force — check all pairs
For each meeting, count how many other meetings overlap with it. The maximum overlap count is the answer. O(n^2) time.
- Time
- O(n^2)
- Space
- O(1)
function minMeetingRooms(intervals) {
let maxRooms = 0;
for (let i = 0; i < intervals.length; i++) {
let rooms = 1;
for (let j = 0; j < intervals.length; j++) {
if (i !== j) {
const [s1, e1] = intervals[i];
const [s2, e2] = intervals[j];
if (s2 < e1 && s1 < e2) rooms++;
}
}
maxRooms = Math.max(maxRooms, rooms);
}
return maxRooms;
}Tradeoff:
2. Optimal — sorted start/end pointer sweep
Separate and sort start times and end times. Use two pointers: advance the end pointer whenever a meeting ends before or when the next starts, freeing a room. Otherwise allocate a new room. O(n log n) dominated by the sort.
- Time
- O(n log n)
- Space
- O(n)
function minMeetingRooms(intervals) {
const starts = intervals.map(([s]) => s).sort((a, b) => a - b);
const ends = intervals.map(([, e]) => e).sort((a, b) => a - b);
let rooms = 0, endPtr = 0;
for (let i = 0; i < starts.length; i++) {
if (starts[i] < ends[endPtr]) {
rooms++;
} else {
endPtr++;
}
}
return rooms;
}Tradeoff:
Roblox-specific tips
Roblox's infrastructure team allocates game server slots for overlapping player sessions — this problem maps directly. The two-pointer sweep is preferred over a min-heap in interviews here because it's easier to reason about correctness under pressure. If the interviewer asks for the heap approach (tracking earliest-ending active room), show it as well — it generalizes to weighted intervals and matches how game-server scheduling actually works.
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
Practice these live with InterviewChamp.AI
Drill Meeting Rooms II and other Roblox interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →