Skip to content

Commit bdfa9a9

Browse files
authored
Update 1024-video-stitching.js
1 parent 7f3c6c4 commit bdfa9a9

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

1024-video-stitching.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,22 @@
33
* @param {number} T
44
* @return {number}
55
*/
6-
const videoStitching = function(clips, T) {
6+
const videoStitching = function (clips, T) {
77
clips.sort((a, b) => a[0] - b[0])
88
let laststart = -1,
99
curend = 0,
1010
count = 0
1111
for (let i = 0; i < clips.length; ) {
12-
if (clips[i][0] > curend) {
13-
return -1
14-
}
12+
if (clips[i][0] > curend) return -1
1513
let maxend = curend
1614
// while one clip's start is before or equal to current end
1715
while (i < clips.length && clips[i][0] <= curend) {
18-
// find out the one with the max possible end
1916
maxend = Math.max(maxend, clips[i][1])
2017
i++
2118
}
2219
count++
2320
curend = maxend
24-
if (curend >= T) {
25-
return count
26-
}
21+
if (curend >= T) return count
2722
}
2823
return -1
2924
}

0 commit comments

Comments
 (0)