def minMeetingRooms(self, intervals): intervals.sort(key=lambda x:x.start) heap =  # stores the end time of intervals for i in intervals: if heap and i.start >= heap: # means two intervals can use the same room heapq.heapreplace(heap, i.end) else: # a new room is allocated heapq.heappush(heap, i.end) return len(heap)
Thank you. Your codes are always clean and easy to follow, I have been learning a lot from your posts.
This should be among the top 5 solutions. Very easy to understand. Thanks again @caikehe !
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.