986. Interval List Intersections
https://leetcode.com/problems/interval-list-intersections/
class Solution:
def intervalIntersection(self, A: List[List[int]], B: List[List[int]]) -> List[List[int]]:
i = 0
j = 0
res = []
while i < len(A) and j < len(B):
startMax = max(A[i][0],B[j][0])
endMin = min(A[i][1],B[j][1])
if startMax <= endMin:
res.append([startMax,endMin])
if A[i][1] == endMin:
i+=1
else:
j+=1
return resLast updated