Code Room
CodingMediumcod-g936
Subject GreedyLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development, Technology

Question

You have clips that each cover a sub-interval [start, end] of a video that runs from time 0 to time T. You want to cover the entire interval [0, T] using as few clips as possible (clips may overlap and may be cut). Return the minimum number of clips needed, or -1 if [0, T] cannot be fully covered. There are at most 1000 clips, and 0 <= start < end, with T between 1 and 1000.

Implement
min_clips(clips: list[list[int]], T: int) → int
Examples
in[[[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]],10]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.