Python Heap 99.25%


  • 2
    class Solution(object):
        def minMeetingRooms(self, intervals):
            count = 0
            h = []
            intervals.sort(key = lambda x: x.start)
            for interval in intervals:
                if not h or interval.start < h[0]:
                    count += 1
                else:
                    heapq.heappop(h)
                heapq.heappush(h, interval.end)
            return count

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.