Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import heapq
  2. class Solution:
  3. def minMeetingRooms(self, intervals: List[List[int]]) -> int:
  4. heap = []
  5. heapq.heapify(heap)
  6. intervals = sorted(intervals, key=lambda x: x[0])
  7. count = 0
  8. for i, pair in enumerate(intervals):
  9. if not heap:
  10. count += 1
  11. else:
  12. if pair[0] < heap[0]:
  13. count += 1
  14. else:
  15. heapq.heappop(heap)
  16. heapq.heappush(heap, pair[1])
  17. return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement