Facebook PixelMeeting Rooms II — Coding Practice
Meeting Rooms IIMedium

Meeting Rooms II

Medium 8.7k50% acceptance
ArrayIntervalsHeapSortingGreedy

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

A meeting that ends exactly when another begins does not require a second room — the room frees up in time.

Example 1
Input: intervals = [[0,30],[5,10],[15,20]]
Output: 2
At time 5 both [0,30] and [5,10] are active, so two rooms are needed.
Example 2
Input: intervals = [[7,10],[2,4]]
Output: 1
The meetings never overlap, so one room suffices.
Example 3
Input: intervals = [[1,5],[8,9],[8,9]]
Output: 2
The two [8,9] meetings overlap and need two rooms.
Constraints
  • 0 ≤ intervals.length ≤ 10⁴
  • intervals[i].length == 2
  • 0 ≤ startᵢ < endᵢ ≤ 10⁶
Asked atGoogleAmazonMetaUber
JavaScript
Loading editor…
Case 1
[[0,30],[5,10],[15,20]]
expected: 2
Case 2
[[7,10],[2,4]]
expected: 1
Case 3
[[1,5],[8,9],[8,9]]
expected: 2
Case 4
[]
expected: 0
Case 5
[[2,7]]
expected: 1
Case 6
[[1,10],[2,7],[3,19],[8,12],[10,20],[11,30]]
expected: 4
Case 7
[[0,5],[5,10],[10,15]]
expected: 1