Intersection of availabilities

Write codeMedium15 minMeta style

Your task

Two tutors publish availability for the same day as closed minute intervals [start, end], each list sorted by start and internally non-overlapping. A joint session can run whenever both are free. Return every window when both are available, as [start, end] pairs sorted by start. Include moment-long windows where the availabilities merely touch (the result may contain [x, x]). Example: [[0,2],[5,10]] and [[1,5],[8,12]] gives [[1,2],[5,5],[8,10]].

Examples

joint_windows(a: list[list[int]], b: list[list[int]]) -> list[list[int]]
Example 1
Inputjoint_windows([[0, 2], [5, 10]], [[1, 5], [8, 12]])
Output[[1, 2], [5, 5], [8, 10]]