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.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

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
1D dynamic programming
Interval covering
Greedy reach
Video stitching
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported