# LC986

**Problem**:

Given two sorted lists of intervals, List A and List B, the intervals in each list are not overlapped or disjoint. Find the overlapping intervals between A and B

**Intuition:**When we see two sorted arrays/Lists, naturally we can think of anther problem that we know how to solve —

**merge two sorted arrays.**

Thus, we can use two pointers to do this problem. We now how to move the pointers according to the

**ending time**of each interval. If A[i].end < B[j].end, we move i because B[j] may have additional time period to overlap with different interval from A.

Secondly, we can easily get the overlapping interval by:

`Interval a = [s1, e1], b = [s2, e2]`

If s2 <= e1 and s1 <= e2 then,

**overlap interval = [max(s1, s2), min(e1, e2)]**

**Algorithm**