Skip to content

Commit 4389942

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

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

1024-video-stitching.js

+20
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,23 @@ const videoStitching = function (clips, T) {
2323
}
2424
return -1
2525
}
26+
27+
// another
28+
29+
/**
30+
* @param {number[][]} clips
31+
* @param {number} T
32+
* @return {number}
33+
*/
34+
const videoStitching = function (clips, T) {
35+
clips.sort((a, b) => a[0] - b[0])
36+
let res = 0
37+
for(let i = 0, start = 0, end = 0, len = clips.length; start < T; start = end, res++) {
38+
for(; i < len && clips[i][0] <= start; i++) {
39+
end = Math.max(end, clips[i][1])
40+
}
41+
if(start === end) return -1
42+
}
43+
return res
44+
}
45+

0 commit comments

Comments
 (0)