You are given two sorted lists of non-overlapping (disjoint) intervals:
listA = [[start1, end1], [start2, end2], ...]
listB = [[startX, endX], [startY, endY], ...]
Your task is to find all intervals where they overlap.
If two intervals overlap, the overlapping portion will form another interval:
If there is no overlap, skip to the next interval.
Return all such overlapping intervals.
Input: listA = [[2,6],[8,11]] listB = [[1,4],[7,10],[12,14]]
Output: [[2,4],[8,10]]
Explanation:
Overlap between [2,6] and [1,4] → [2,4] Overlap between [8,11] and [7,10] → [8,10]
Input: listA = [[1,2],[5,7]] listB = [[3,4],[6,8]]
Output: [[6,7]]
Accepted:
Submission: