Complete the code to sort the intervals by their start time.
intervals.sort(key=lambda x: x[[1]])The intervals are sorted by the first element (start time) using x[0].
Complete the code to initialize a min-heap for tracking end times.
import heapq heap = [] heapq.[1](heap, intervals[0][1])
Use heapq.heappush to add an element to the heap.
Fix the error in the condition to check if the current meeting can reuse a room.
if intervals[i][0] [1] heap[0]:
The current meeting start time must be greater or equal to the earliest end time to reuse the room.
Fill both blanks to pop the earliest end time and push the current meeting's end time.
heapq.[1](heap) heapq.[2](heap, intervals[i][1])
Use heappop to remove the earliest end time and heappush to add the current meeting's end time.
Fill all three blanks to complete the function that returns minimum meeting rooms required.
def minMeetingRooms(intervals): if not intervals: return 0 intervals.sort(key=lambda x: x[[1]]) import heapq heap = [] heapq.heappush(heap, intervals[0][1]) for i in range(1, len(intervals)): if intervals[i][0] [2] heap[0]: heapq.heappop(heap) heapq.heappush(heap, intervals[i][[3]]) return len(heap)
Sort by start time using x[0], check if start >= earliest end time, and push the end time at index 1.