Skip to main content

Meeting Rooms II

Question

None

Example 1
Input: [[0,30],[5,10],[15,20]]

Output: 2

Solution

all//Meeting Rooms II.py


def minMeetingRooms(intervals):
if not intervals:
return 0

start_times = sorted([i[0] for i in intervals])
end_times = sorted([i[1] for i in intervals])

num_rooms = 0
end_index = 0

for start in start_times:
if start < end_times[end_index]:
num_rooms += 1
else:
end_index += 1

return num_rooms