Skip to content
DeepForgeby svx
All problems
EasyAlgorithmsal-051

Meeting Rooms

Problem

Given meeting time intervals as [start, end] pairs, return True if one person can attend every meeting without overlap.

Sort intervals by start time and check that each meeting begins at or after the previous one ends. Touching endpoints, such as [1, 2] and [2, 3], do not count as overlap.

Hint

After sorting by start, only consecutive pairs can conflict.

Test cases

case 1
in: [[[0,30],[5,10],[15,20]]]
expected: false
case 2
in: [[[7,10],[2,4]]]
expected: true
case 3
in: [[]]
expected: true
case 4
in: [[[1,5]]]
expected: true
case 5
in: [[[1,2],[2,3]]]
expected: true
Starter codePython
def can_attend_all(intervals):
    # Your code here
    pass

5 test cases · run your code against them in the editor