My Python Solution 84ms~


  • 0
    C
    def minMeetingRooms(self, intervals):
            cnt = 1
            if not intervals:
                return 0
            intervals.sort(key=lambda x: x.start)
            tmp = [] # store the interval index that has been discarded
            for i in xrange(1, len(intervals)):
                if intervals[i].start >= intervals[i-1].end:
                    tmp.append(i-1)
                    continue
                if intervals[i-1].start <= intervals[i].start < intervals[i-1].end:
                    j = 0
                    while j < i:
                        if intervals[j].end <= intervals[i].start and j not in tmp:
                            tmp.append(j)
                            break
                        j += 1
                    else:
                        cnt += 1
            return cnt

Log in to reply
 

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