Overlaps of Two Schedules
first and second are two schedules. Each is a list of busy slots [start, end] with start <= end, sorted by start, and within one schedule the slots never overlap or touch: every slot ends strictly before the next one starts. Return every time range during which both schedules are busy, as a list of [start, end] pairs sorted by start.
Two slots overlap when they share at least one point: [2, 5] and [5, 7] share the single point 5, which gives [5, 5]. Return an empty list if the schedules never overlap. Do not change the inputs.
Example 1
[0, 2] meets [1, 5] on [1, 2]; [5, 10] meets [1, 5] on the point 5 and [8, 12] on [8, 10]; [13, 23] meets [15, 24] on [15, 23]; [24, 25] meets [15, 24] on 24 and [25, 26] on 25.
Example 2
The second schedule has no slots, so nothing can overlap.
Constraints
0 <= len(first), len(second) <= 500 <= start <= end <= 1000for every slot- within one schedule each slot ends strictly before the next one starts
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.