Meeting Rooms
Merge Intervals
Problem
Given an array of intervals representing āNā appointments, find out if a person can attend all the appointments.
Thought Process
This is the exact same as Merge Intervals but in this problem we just return True or False if the merge or not
Solution
def can_attend_all_appointments(intervals):
intervals = sorted(intervals)
curr = intervals[0]
for i in range(1, len(intervals)):
nextI = intervals[i]
if curr[1] < nextI[0]:
continue
else:
return False
return True
#Time: O(n)
#Space: O(1)
Last updated
Was this helpful?