1229. Meeting Scheduler
interval
Input: slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 8
Output: [60,68]Input: slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 12
Output: []Last updated
interval
Input: slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 8
Output: [60,68]Input: slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 12
Output: []Last updated
class Solution:
def minAvailableDuration(self, slots1: List[List[int]], slots2: List[List[int]], duration: int) -> List[int]:
n,m = len(slots1), len(slots2)
slots1.sort()
slots2.sort()
i = j = 0
while i < n and j < m:
s1, e1 = slots1[i]
s2, e2 = slots2[j]
start = max(s1, s2)
end = min(e1, e2)
if end - start >= duration:
return [start, start + duration]
if e2 > e1:
i += 1
elif e1 > e2:
j += 1
else:
i += 1
j += 1
return []