Meeting Rooms II
Problem statement
Each pair [start,end] is a meeting that occupies one room during the half-open interval [start,end). Return the fewest rooms needed for all meetings.
A room can be reused when one meeting ends at exactly the next meeting's start time. The meetings may be given in any order. Return zero for an empty input.
Function
minMeetingRooms(intervals: int[][]) → intExamples
Example 1
intervals = [[0,10],[5,8],[8,12]]return = 2The first and second meetings need two rooms at time five. At time eight, the second meeting ends and its room can be reused for the third. Two rooms suffice.
Example 2
intervals = [[1,2],[2,3]]return = 1The first meeting ends when the second starts, so both can use one room.
Constraints
0 <= intervals.length <= 500- Every interval has exactly two entries.
-1000000 <= intervals[i][j] <= 1000000- Each interval satisfies start < end.