1
# Runtime: 325 ms (Top 13.56%) | Memory: 15.2 MB (Top 15.52%)2
from collections import deque6
def intervalIntersection(7
self, firstList: List[List[int]], secondList: List[List[int]]12
if len(firstList) == 0 or len(secondList) == 0:15
first_queue = deque(firstList)16
second_queue = deque(secondList)18
first = first_queue.popleft()19
second = second_queue.popleft()21
while first_queue or second_queue:23
if first[1] < second[0]:25
first = first_queue.popleft()28
if second[1] < first[0]:29
if len(second_queue) > 0:30
second = second_queue.popleft()34
if first[0] <= second[0] and second[0] <= first[1]:35
if first[1] <= second[1]:36
answer.append([second[0], first[1]])37
if len(first_queue) > 0:38
first = first_queue.popleft()44
if len(second_queue) > 0:45
second = second_queue.popleft()48
if second[0] <= first[0] and first[0] <= second[1]:49
if second[1] <= first[1]:50
answer.append([first[0], second[1]])51
if len(second_queue) > 0:52
second = second_queue.popleft()58
if len(first_queue) > 0:59
first = first_queue.popleft()63
if first[0] <= second[0] and second[0] <= first[1]:64
if first[1] <= second[1]:68
if answer[-1] != [second[0], first[1]]:69
answer.append([second[0], first[1]])71
answer.append([second[0], first[1]])74
if answer[-1] != second:78
elif second[0] <= first[0] and first[0] <= second[1]:79
if second[1] <= first[1]:81
if answer[-1] != [first[0], second[1]]:82
answer.append([first[0], second[1]])84
answer.append([first[0], second[1]])87
if answer[-1] != first: