Skip to content

Commit 452fcea

Browse files
authored
Update 1024-video-stitching.js
1 parent 4389942 commit 452fcea

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

1024-video-stitching.js

+21
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,24 @@ const videoStitching = function (clips, T) {
4343
return res
4444
}
4545

46+
47+
// another
48+
49+
/**
50+
* @param {number[][]} clips
51+
* @param {number} T
52+
* @return {number}
53+
*/
54+
const videoStitching = function (clips, T) {
55+
const dp = Array(T + 1).fill( T + 1 )
56+
dp[0] = 0
57+
for(let i = 0; i <= T; i++) {
58+
for(let c of clips) {
59+
if(i >= c[0] && i <= c[1]) dp[i] = Math.min(dp[i], dp[c[0]] + 1)
60+
}
61+
if(dp[i] === T + 1) return -1
62+
}
63+
return dp[T]
64+
}
65+
66+

0 commit comments

Comments
 (0)