Facebook Pixel

Meeting Rooms II

Given an array of meeting time intervals where intervals[i] = [start, end], return the minimum number of conference rooms required so that no two overlapping meetings share a room.

Drag the time line above to see how many meetings run at once. The busiest moment is the number of rooms you need.

Input & Output
Input
intervals — an array of meeting time intervals where intervals[i] = [starti, endi]
Output
the minimum number of conference rooms required
Example
Input
intervals = [[0,30],[5,10],[15,20]]
Output
2
Explanation
We need two meeting rooms: Room 1: [0,30] Room 2: [5,10], [15,20]
Example
Input
intervals = [[7,10],[2,4]]
Output
1
Explanation
We need one meeting room: Room 1: [2,4], [7,10]
Example
Input
intervals = [[0,30],[5,10],[15,20],[5,15]]
Output
3
Explanation
We need three meeting rooms: Room 1: [0,30] Room 2: [5,10], [15,20] Room 3: [5,15]
Constraints
  • 1 <= intervals.length <= 10^4
  • 0 <= starti < endi <= 10^6

Try it yourself

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro