File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change 3
3
* @param {number } T
4
4
* @return {number }
5
5
*/
6
- const videoStitching = function ( clips , T ) {
6
+ const videoStitching = function ( clips , T ) {
7
7
clips . sort ( ( a , b ) => a [ 0 ] - b [ 0 ] )
8
8
let laststart = - 1 ,
9
9
curend = 0 ,
10
10
count = 0
11
11
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
15
13
let maxend = curend
16
14
// while one clip's start is before or equal to current end
17
15
while ( i < clips . length && clips [ i ] [ 0 ] <= curend ) {
18
- // find out the one with the max possible end
19
16
maxend = Math . max ( maxend , clips [ i ] [ 1 ] )
20
17
i ++
21
18
}
22
19
count ++
23
20
curend = maxend
24
- if ( curend >= T ) {
25
- return count
26
- }
21
+ if ( curend >= T ) return count
27
22
}
28
23
return - 1
29
24
}
You can’t perform that action at this time.
0 commit comments