Back to course home
0% completed
Vote For New Content
Corrected Code in Python
anup kalia
Apr 18, 2024
class Solution: def findMinimumMeetingRooms(self, meetings): if not meetings: return 0 # sort the meetings by start time meetings.sort(key=lambda x: x.start) minRooms = 0 minHeap = [] for meeting in meetings: # remove all meetings that have ended while minHeap and meeting.start >= minHeap[0]: heapq.heappop(minHeap) # add the current meeting into the minHeap heapq.heappush(minHeap, meeting.end) # all active meetings are in the minHeap, so we need rooms for all of them. minRooms = max(minRooms, len(minHeap)) return minRooms
3
0
Comments
Comments
Aingkaran Jegaa year ago
yea this makes more sense meeting.end should be pushed into the heapq
On this page