We calculate the intersection and merge them as is.
class Solution:
def intervalIntersection(self, firstList: List[List[int]], secondList: List[List[int]]) -> List[List[int]]:
intersection = []
i = 0
j = 0
while i < len(firstList) and j < len(secondList):
[s1, e1], [s2, e2] = firstList[i], secondList[j]
low = max(s1, s2)
high = min(e1, e2)
if low <= high:
intersection.append([low, high])
if e1 < e2:
i += 1
else:
j += 1
return intersection