‹ DS&A interview · Socratic
DSA · Intervals · #116

Meeting Rooms II

Module 67 · difficulty 3/5·30:00starts on first keystroke

Given an array `intervals` where `intervals[i] = [start_i, end_i]` represents a meeting that occupies the half-open time range `[start_i, end_i)`, return the **minimum number of conference rooms** required so that no two meetings sharing a room overlap. Two meetings overlap if one starts strictly before the other ends. A meeting that starts exactly when another ends does NOT overlap (the room can be reused). Implement the function `minMeetingRooms(intervals)` that returns an integer.

Examples
  • intervals = [[0,30],[5,10],[15,20]] 2[0,30] overlaps both [5,10] and [15,20], so it needs its own room; [5,10] and [15,20] are disjoint and can share the second room.
  • intervals = [[7,10],[2,4]] 1The two meetings do not overlap, so a single room suffices.
  • intervals = [[1,5],[5,9],[2,6]] 2[1,5] and [5,9] touch only at 5 and don't overlap, but [2,6] overlaps both, forcing a second room.
Constraints
  • · 1 <= intervals.length <= 10^4
  • · 0 <= start_i < end_i <= 10^6
  • · Each intervals[i] has exactly two integers.
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.