Skip to content
Decoder

Video Stitching

Medium

Problem

A sporting event lasted time seconds. You have video clips, each clips[i] = [start, end], and clips may overlap or be any length. You can cut a clip into smaller pieces freely. Return the minimum number of clips needed to cover the whole event [0, time], or -1 if it cannot be covered.

Example 1

Input
clips = [[0, 2], [4, 6], [8, 10], [1, 9], [1, 5], [5, 9]], time = 10
Output
3

Example 2

  ([0, 2], [1, 9], [8, 10])

Example 3

Input
clips = [[0, 1], [1, 2]], time = 5
Output
-1

Constraints

  • 1 <= clips.length <= 100
  • 0 <= start <= end <= 100
  • 1 <= time <= 100

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.