Meeting Rooms

Problem Link 1: https://leetcode.com/problems/meeting-rooms/

Problem Link 2: https://www.lintcode.com/problem/920/

from typing import (
    List,
)
from lintcode import (
    Interval,
)

"""
Definition of Interval:
class Interval(object):
    def __init__(self, start, end):
        self.start = start
        self.end = end
"""

class Solution:
    """
    @param intervals: an array of meeting time intervals
    @return: if a person could attend all meetings
    """
    def can_attend_meetings(self, intervals: List[Interval]) -> bool:
        # Write your code here
        n=len(intervals)
        arr=[]
        for i in intervals:
            arr.append([i.start,i.end])
        arr.sort(key=lambda x:x[0])
        for i in range(1,n):
            if(arr[i][0]>=arr[i-1][1]):
                continue
            else:
                return False
        else:
            return True

Last updated