Python Solution using priority queue but cannot pass some test cases

  • 0

    My solution using priority queue cannot pass test case like [[9,10],[4,9],[4,17]]
    The result should be 2 but I returned 3, can anyone tell me how to fix this bug?
    Thanks so much!

    def minMeetingRooms(self, intervals):
        :type intervals: List[Interval]
        :rtype: int
        if intervals is None or len(intervals) == 0:
            return 0
        intervals.sort(key = lambda x : x.start)
        pq = []
        for i in range(1, len(intervals)):
            if intervals[i].start >= pq[-1]:
        return len(pq)

Log in to reply

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