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 = [[0, 2], [5, 10]], b = [[1, 5], [8, 12]]
Output: [[1, 2], [5, 5], [8, 10]]
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