Fewest Clips to Cover a Full YouTube Video Timeline
Last updated: November 29, 2026
Quick Overview
Creators upload overlapping clips of a livestream, each covering a time interval [start, end]. Return the fewest clips whose union covers the whole range [0, T], or -1 if impossible.
0
0
0 solved
Creators upload overlapping clips of a livestream, each covering a time interval [start, end]. Return the fewest clips whose union covers the whole range [0, T], or -1 if impossible.
A Google onsite problem that can be solved by DP over time or by a greedy reach scan, and interviewers often ask for both. The signal is a correct DP definition over prefix coverage, plus an argument for the faster greedy.
What the Interviewer Expects
- Define best[t] as the fewest clips covering [0, t]
- Transition from best[s] for any clip with s < t <= e
- Return -1 when coverage has a gap
- Give the O(T + n) greedy using max reach per start
- Explain why the greedy matches the DP
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Each clip has a cost; minimize total cost instead.
- Times are real numbers up to 10^9.
- Return the clips used.
- Clips can be trimmed but each use costs one unit per second kept.
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list clips of [start, end] integer pairs and integer T > 0. Clips may overlap and may extend past T. Choose the fewest clips whose union contains [0, T]. Output that count or -1....
High-Level Design
DP view: best[t] is the minimum number of clips whose union covers [0, t]. best[0] = 0. For t from 1 to T, any clip [s, e] with s < t <= e can be the last clip, extending coverage from some poin...