Minimum shift coverage
A dispatcher must keep at least one courier on duty for the entire window from time 0 to time t (t >= 1). shifts[i] = [start, end] means courier i is willing to work that whole span. Return the minimum number of shifts to select so that every moment in [0, t] is covered, or -1 if it cannot be done. Example: shifts [[0,2],[1,5],[4,7]] with t = 6 needs 3 shifts.
Implement
min_shifts(shifts: list[list[int]], t: int) → intExamples
in
[[[0,2],[1,5],[4,7]],6]out3What 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
solution.py
InputExpectedGot
[[[0,2],[1,5],[4,7]],6]3not run yetsample