Overlap of two schedules
Two calendars, a and b, each list the closed ranges [start, end] when one person is free, with start <= end. Each list is sorted by start and its ranges are disjoint: no two share a point. Return every range where a range of a and a range of b overlap, sorted by start. Ranges that meet at one point share that point: [1, 3] and [3, 5] share [3, 3].
Either list may be empty. Aim for O(n + m), one pass over both lists.
Besides the tests, one large input (two lists of 2,800 ranges) with a ~150 ms limit (scaled to your device's speed): brute force won't pass.
Examples
schedule_overlap([[1,4],[6,9],[12,15]], [[2,7],[8,13]])→[[2,4],[6,7],[8,9],[12,13]]schedule_overlap([[1,3],[5,8]], [[3,5]])→[[3,3],[5,5]]schedule_overlap([[1,10]], [[2,3],[5,6],[9,12]])→[[2,3],[5,6],[9,10]]