Skip to content

Commit 8e252bf

Browse files
authored
Improved task 1024.
1 parent bb2a7f2 commit 8e252bf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/g1001_1100/s1024_video_stitching/Solution.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ public int videoStitching(int[][] clips, int time) {
99
Arrays.sort(clips, (a, b) -> a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]);
1010
int count = 0;
1111
int covered = 0;
12-
for (int i = 0, start = 0; start < time; count++, start = covered) {
12+
int i = 0;
13+
int start = 0;
14+
while (start < time) {
1315
while (i < clips.length && clips[i][0] <= start) {
1416
covered = Math.max(covered, clips[i][1]);
1517
i++;
1618
}
1719
if (start == covered) {
1820
return -1;
1921
}
22+
count++;
23+
start = covered;
2024
}
2125
return count;
2226
}

0 commit comments

Comments
 (0)