HTMLify
Meeting Rooms
Views: 14 | Author: prakhardoneria
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | class Solution: def canAttend(self, arr): # 1. Sort the meetings based on start times # If start times are equal, it sorts by end times arr.sort() # 2. Iterate through the meetings starting from the second one for i in range(1, len(arr)): # previous_end = arr[i-1][1] # current_start = arr[i][0] # 3. If the current meeting starts before the previous one ends, # it's impossible to attend all. if arr[i][0] < arr[i-1][1]: return False # 4. If no overlaps are found, return True return True |