Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required.

You need to determine the maximum number of meetings that are happening at the same time, which equals the minimum number of rooms needed.

For example, if meetings are [[0,30],[5,10],[15,20]], we need 2 rooms because meetings [0,30] and [5,10] overlap.

Input & Output

Example 1 — Basic Overlapping
$ Input: intervals = [[0,30],[5,10],[15,20]]
Output: 2
💡 Note: Meeting [0,30] overlaps with both [5,10] and [15,20], but [5,10] and [15,20] don't overlap with each other. Maximum concurrent meetings is 2 (at times 5-10 and 15-20).
Example 2 — No Overlap
$ Input: intervals = [[7,10],[2,4]]
Output: 1
💡 Note: The meetings don't overlap: [2,4] ends before [7,10] starts. Only 1 room needed since they can use the same room sequentially.
Example 3 — Adjacent Meetings
$ Input: intervals = [[1,5],[8,9],[8,9]]
Output: 2
💡 Note: First meeting [1,5] doesn't overlap with others. The two [8,9] meetings start at exactly the same time, so we need 2 rooms for them.

Constraints

  • 1 ≤ intervals.length ≤ 104
  • 0 ≤ starti < endi ≤ 106

Visualization

Tap to expand
Meeting Rooms II: Find Minimum Conference RoomsTimeline:010152030[0,30] - Meeting 1[5,10][15,20]Max Overlap:At time 5-10:2 meetings activeAt time 15-20:2 meetings activeSame as maximumAnswer: 2 conference rooms required
Understanding the Visualization
1
Input Meetings
Given meeting time intervals [[0,30],[5,10],[15,20]]
2
Find Overlaps
Identify which meetings happen simultaneously
3
Count Rooms
Minimum rooms needed = maximum concurrent meetings
Key Takeaway
🎯 Key Insight: The minimum rooms needed equals the maximum number of meetings happening at any point in time
Asked in
Google 85 Facebook 72 Amazon 68 Microsoft 45 Apple 38
285.0K Views
High Frequency
~25 min Avg. Time
4.2K Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen