Meeting Rooms

Interval
Easy

Approach

Diagrams

Analysis

Time

O(n log(n))

Space

O(1)
class Solution:
    def canAttendMeetings(self, intervals):
        lastIdx, curIdx = 0, 1

        intervals.sort(key=lambda interval: interval[0])

        while curIdx < len(intervals):
            lastEnd, curStart = intervals[lastIdx][1], intervals[curIdx][0]

            if lastEnd > curStart:
                return False

            lastIdx += 1
            curIdx += 1

        return True

Learn

#Greedy

Videos