Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def intervalIntersection(self, A: List[List[int]], B: List[List[int]]) -> List[List[int]]:
- p1 = 0
- p2 = 0
- res = []
- while p1 < len(A) and p2 < len(B):
- start = max(A[p1][0], B[p2][0])
- end = min(A[p1][1], B[p2][1])
- if start <= end:
- res.append([start, end])
- if A[p1][1] < B[p2][1]:
- p1 += 1
- else:
- p2 += 1
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement