Simiar as 1229. Meeting Scheduler
class Solution(object):
def intervalIntersection(self, firstList, secondList):
"""
:type firstList: List[List[int]]
:type secondList: List[List[int]]
:rtype: List[List[int]]
"""
i = j = 0
ans = []
while(i < len(firstList) and j < len(secondList)):
startOverlap = max(firstList[i][0], secondList[j][0])
endOverlap = min(firstList[i][1], secondList[j][1])
print(f"[{startOverlap}, {endOverlap}]")
if endOverlap >= startOverlap:
ans.append([startOverlap, endOverlap])
if firstList[i][1] > secondList[j][1]: j += 1
else: i += 1
return ans