Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import heapq
- class Solution:
- def minMeetingRooms(self, intervals: List[List[int]]) -> int:
- heap = []
- heapq.heapify(heap)
- intervals = sorted(intervals, key=lambda x: x[0])
- count = 0
- for i, pair in enumerate(intervals):
- if not heap:
- count += 1
- else:
- if pair[0] < heap[0]:
- count += 1
- else:
- heapq.heappop(heap)
- heapq.heappush(heap, pair[1])
- return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement