Skip to content
DeepForgeby svx
All problems
MediumAlgorithmsal-056

Minimum Meeting Rooms

Problem

Return the minimum number of meeting rooms needed to schedule all intervals without overlap.

Create a start event (+1) and an end event (-1) for each interval, sort all events by time, and process ends before starts at the same time. The answer is the maximum number of simultaneously active meetings.

Hint

Sorting time, delta with ends as -1 makes meetings that touch endpoints not overlap.

Test cases

case 1
in: [[[0,30],[5,10],[15,20]]]
expected: 2
case 2
in: [[[7,10],[2,4]]]
expected: 1
case 3
in: [[]]
expected: 0
case 4
in: [[[1,5],[5,10]]]
expected: 1
case 5
in: [[[1,10],[2,3],[4,5]]]
expected: 2
Starter codePython
def min_meeting_rooms(intervals):
    # Your code here
    pass

5 test cases · run your code against them in the editor