Code Room
CodingMediumcod-g1440
Subject GreedyLevel Entry–Mid~16 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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) → int
Examples
in[[[0,2],[1,5],[4,7]],6]out3
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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.