commit 4d48c46926b5868ade4f9837d24f4409190fb0ca
parent 6f19a39f522baa6e0f87c269ef9175a626bbffd3
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Wed, 29 May 2024 11:09:10 +0200
1 Random Problem
Diffstat:
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/Problems/1024.cpp b/Problems/1024.cpp
@@ -0,0 +1,18 @@
+class Solution {
+ public:
+ int videoStitching(vector<vector<int>> &clips, const int time) const {
+ const int n = size(clips);
+ int res = 0, start = 0, finish = 0;
+
+ sort(begin(clips), end(clips));
+ for (int i = 0; start < time; res++) {
+ for (; i < n && clips[i][0] <= start; i++) {
+ finish = max(finish, clips[i][1]);
+ }
+ if (start == finish) return -1;
+ start = finish;
+ }
+
+ return res;
+ }
+};
diff --git a/README.md b/README.md
@@ -618,6 +618,7 @@ for solving problems.
| 1020 | Medium | [Number of Enclaves](Problems/1020.cpp) |
| 1022 | Easy | [Sum of Root To Leaf Binary Numbers](Problems/1022.cpp) |
| 1023 | Medium | [Camelcase Matching](Problems/1023.cpp) |
+| 1024 | Medium | [Video Stitching](Problems/1024.cpp) |
| 1026 | Medium | [Maximum Difference Between Node and Ancestor](Problems/1026.cpp) |
| 1027 | Medium | [Longest Arithmetic Subsequence](Problems/1027.cpp) |
| 1029 | Medium | [Two City Scheduling](Problems/1029.cpp) |