FastPrepMeeting Rooms II

Meeting Rooms II

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREENONSITE INTERVIEW
Learn

Problem statement

You are given meeting time intervals where each row [start, end] uses a half-open interval: a meeting occupies a room from start up to, but not including, end.

Return the minimum number of meeting rooms required so that every meeting can take place. A room whose meeting ends at time t may be reused by another meeting that starts at time t.

Function

minMeetingRooms(intervals: int[][]) → int

Examples

Example 1

intervals = [[0,30],[5,10],[15,20]]return = 2

The meeting [0,30] overlaps both shorter meetings, but the two shorter meetings do not overlap each other.

Example 2

intervals = [[7,10],[2,4]]return = 1

The meetings are disjoint, so one room can host both.

Example 3

intervals = [[1,5],[5,9],[5,6]]return = 2

The room used by [1,5] is available at time 5, while the two meetings beginning at 5 need two rooms together.

Constraints

  • 0 <= intervals.length <= 100000.
  • Each interval has exactly two integers [start, end].
  • 0 <= start < end <= 10^9.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public int minMeetingRooms(int[][] intervals) {
    // Write your code here.
}
intervals[[0,30],[5,10],[15,20]]
expected2
Checking account…