Python simple solution easy to understand


  • 2
    P
    class Solution(object):
        def canAttendMeetings(self, intervals):
            """
            :type intervals: List[Interval]
            :rtype: bool
            """
            if len(intervals) < 2:
                return True
            else:
                intervals = sorted(intervals, key=lambda x: x.start)
                for p, q in zip(intervals, intervals[1:]):
                    if q.start < p.end:
                        return False
                return True

Log in to reply
 

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