SoFi may need to find times when both a member and a financial specialist are available for an appointment. Given two lists of available time windows, return every time window when both schedules are open.
Each window is represented as a two-element list [start, end] and follows half-open interval semantics: it includes start but excludes end. The input lists are sorted by start time, and windows within each list do not overlap. Return the shared windows in chronological order. A shared window must have positive duration, so touching windows such as [10, 12] and [12, 15] do not overlap.
Implement find_shared_openings(schedule_a, schedule_b):
[start, end] and start < end.Example 1
schedule_a = [[9, 12], [13, 17]]
schedule_b = [[10, 11], [11, 14], [16, 18]]
Output: [[10, 11], [11, 12], [13, 14], [16, 17]]
Each output interval is a period contained in one window from each schedule.
Example 2
schedule_a = [[8, 10], [12, 13]]
schedule_b = [[10, 12]]
Output: []
The windows only touch at boundaries, so there is no positive-length overlap.
10^5 windows.0 through 10^9.len(schedule_a) + len(schedule_b) - 1 windows.def find_shared_openings(schedule_a, schedule_b):