253. Meeting Rooms II
https://leetcode.com/problems/meeting-rooms-ii/
Python
Priority Queue
import heapq
class Solution:
def minMeetingRooms(self, intervals: List[List[int]]) -> int:
if not intervals:
return 0
intervals.sort(key=lambda interval: interval[0])
heap = []
heapq.heappush(heap, intervals[0][1])
for interval in intervals[1:]:
start, end = interval
if heap[0] <= start:
heapq.heappop(heap)
heapq.heappush(heap, end)
return len(heap)