To find out the number of concurrent meetings, we can merge the start/end times into one array keyed by timestamp + the action (if a meeting starts, one more meeting room is required, and if a meeting ends, one less meeting room is required). We then calculate the maximum number of concurrent meetings and return that.
class Solution:
def minMeetingRooms(self, intervals: List[List[int]]) -> int:
times = []
for start, end in intervals:
times.append((start, +1))
times.append((end, -1))
times.sort()
max_rooms, curr_rooms = 0, 0
for _, meeting in times:
curr_rooms += meeting
max_rooms = max(max_rooms, curr_rooms)
return max_rooms