We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bb2a7f2 commit 8e252bfCopy full SHA for 8e252bf
src/main/java/g1001_1100/s1024_video_stitching/Solution.java
@@ -9,14 +9,18 @@ public int videoStitching(int[][] clips, int time) {
9
Arrays.sort(clips, (a, b) -> a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]);
10
int count = 0;
11
int covered = 0;
12
- for (int i = 0, start = 0; start < time; count++, start = covered) {
+ int i = 0;
13
+ int start = 0;
14
+ while (start < time) {
15
while (i < clips.length && clips[i][0] <= start) {
16
covered = Math.max(covered, clips[i][1]);
17
i++;
18
}
19
if (start == covered) {
20
return -1;
21
22
+ count++;
23
+ start = covered;
24
25
return count;
26
0 commit comments