clean and fast python solution, 65ms


  • 0
    B

    A new meeting increase the overlap, an end of meeting reduce the overlap

    class Solution(object):
        def minMeetingRooms(self, intervals):
            starts = sorted([i.start for i in intervals])
            ends = sorted([i.end for i in intervals])
            ret = count = 0
            s = e = 0
            while s < len(starts) and e < len(ends):
                if starts[s] < ends[e]:
                    count += 1; s += 1
                    ret = max(ret, count)
                else:
                    count -= 1; e += 1
            return ret
    

Log in to reply
 

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