On-call coverage gaps
Merge overlapping on-call shifts and report the gaps inside a window where nobody is paged.
Statement
On-call shifts are (start, end) Unix timestamps that may overlap or touch. Write coverage_gaps(shifts, window) that returns the ranges inside window during which nobody is on call, in order.
Shifts outside the window are irrelevant except where they overlap it.
Examples
window = (0, 100)
shifts = [(0, 30), (25, 50), (60, 80)] → [(50, 60), (80, 100)] shifts = [(−10, 110)] → []
Constraints
Up to 10⁵ shifts. Shifts may start before or end after the window. Touching shifts (end == next start) leave no gap.
Free to try · sign in to save your attemptSolve it in the editor with visible tests
Open in the app