« Back

Meeting Rooms

LeetCode Premium

Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.

Solution

Cleaned up code

Time spent: 1m | Runtime: 15.07% | Memory: 57.14%

class Solution:
    def canAttendMeetings(self, intervals: List[List[int]]) -> bool:
        intervals.sort()
        prev_end = -1
        for start, end in intervals:
            if start < prev_end:
                return False
            prev_end = end
        return True