Code RoomSupport rota coverage gaps
EasyPrep Room Coding #4752

Support rota coverage gaps

CodingAlgorithms & data structuresEntry–Mid~16 min

A team publishes its overnight support rota as a list of shifts, each written as a pair [start, end] in minutes counted from midnight. A shift covers every minute from start up to but not including end. The shifts arrive in no particular order, two of them can cover the same minute, a cancelled shift can carry start equal to end, and a shift that began the previous evening can carry a negative start. The rota is meant to cover the window running from minute 0 up to but not including day_end. Clip each shift to that window, then return every stretch inside the window with nobody on duty, each written as a pair [begin, finish] read the same way, sorted by begin. Return an empty list when the window is covered end to end, and also when day_end is zero or negative.

Implement
oncall_coverage_gaps(shifts: list[list[int]], day_end: int) → list[list[int]]
Examples
in[[[0,480],[480,960]],1440]out[[960,1440]]
in[[[120,300],[240,400],[600,660]],720]out[[0,120],[400,600],[660,720]]
in[[],60]out[[0,60]]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 16 min
InputExpectedGot
[[[0,480],[480,960]],1440][[960,1440]]not run yetsample
[[[120,300],[240,400],[600,660]],720][[0,120],[400,600],[660,720]]not run yetsample
[[],60][[0,60]]not run yetsample