Given two lists of closed intervals a and b, each sorted by start and non-overlapping within itself, return the list of all intervals that lie in both a and b, sorted by start. A single shared point such as [5, 5] counts.
Examples
Input: a = [[2, 4], [7, 13]], b = [[3, 7], [11, 15]]
Output: [[3, 4], [7, 7], [11, 13]]
Input: a = [[1, 3]], b = [[4, 6]]
Output: []
Constraints
0 <= len(a), len(b) <= 10**5- Target: O(len(a) + len(b)) time, O(1) extra space beyond the output.
Goals
- Compute the overlap of two closed intervals with max/min
- Advance the interval that ends first