O(nlgn) without using priority queue version


  • 0
    Y
    class Solution(object):
        def minMeetingRooms(self, intervals):
            """
            :type intervals: List[Interval]
            :rtype: int
            """
            s=[i.start for i in intervals]
            s.sort()
            e=[e.end for e in intervals]
            e.sort()
            i=j=r=0
            minRooms=0
            while i<len(s):
                r+=1
                while j<len(e) and e[j]<=s[i]:
                    r-=1
                    j+=1
                i+=1
                minRooms=max(r,minRooms)
            return minRooms

Log in to reply
 

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