Description
You are given a series of video clips from a sporting event that occurred for time seconds. Return the minimum number of clips needed so that we can cut the clips into segments that cover the entire sporting event [0, time], or -1 if impossible.
Examples
Input:
clips = [[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]], time = 10Output:
3Explanation:
[0,2] + [1,9] + [8,10] covers [0,10].
Input:
clips = [[1]], time = 10Output:
1Explanation:
Minimal case with a single-element matrix.
Input:
clips = [[0,4],[2,8],[7,12]], time = 12Output:
3Explanation:
The requirement is all three clips to cover [0,12]. [0,4] covers the beginning, [2,8] fills the middle with overlap, and [7,12] covers the end. It is not possible to reduce to fewer clips because removing any clip would leave gaps in coverage.
Constraints
- •
1 ≤ clips.length ≤ 100 - •
0 ≤ starti ≤ endi ≤ 100