Skip to content

Commit 2ee97d7

Browse files
committed
1024
1 parent 207f6d3 commit 2ee97d7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

1024. Video Stitching.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int videoStitching(vector<vector<int>>& clips, int T) {
5+
6+
sort(clips.begin(),clips.end());
7+
vector<int> dp(T+1,INT_MAX);
8+
9+
dp[0] = 0;
10+
for(vector<int> array:clips){
11+
for(int i=array[0];i<=min(T,array[1]);i++){
12+
if(!(dp[array[0]]<INT_MAX)){
13+
break;
14+
}
15+
for(int j=array[0];j<i;j++){
16+
dp[i] = min(dp[i],dp[j]+1);
17+
}
18+
}
19+
}
20+
21+
return dp[T]<INT_MAX?dp[T]:-1;
22+
}

0 commit comments

Comments
 (0)