3
static bool comp(vector<int> a, vector<int> b) {11
int videoStitching(vector<vector<int>> &clips, int time) {12
sort(clips.begin(), clips.end(), comp);13
vector<vector<int>> res;14
// check if 0 is present or not15
if (clips[0][0] != 0) return -1;16
res.push_back(clips[0]);17
// if 1. First check if the required interval is already covered or not18
// if 2. If the first value of the already inserted element in res is equal,19
// then the next value if obviously smaller interval because of custom20
// sorting so, we should skip it if 3. Cover every value by checking if the21
// interval is required or not (already present?) if required then insert it22
// if 3.1. Check if the interval to be inserted covers the interval at the23
// back for example [0,4], [2,6], now if we were to insert the interval [4,24
// 7], then [2,6] is no more requried, then pop_back.25
for (int i = 1; i < clips.size(); i++) {26
if (res.back()[1] >= time) break;27
if (clips[i][0] == res.back()[0]) continue;28
if (clips[i][1] > res.back()[1]) {29
if (res.size() > 1 and res[res.size() - 2][1] >= clips[i][0]) res.pop_back();30
res.push_back(clips[i]);33
// Check if the compelete range from 0 to time is covered or not35
for (int i = 1; i < res.size(); i++) {36
if (res[i][0] > prev) return -1;39
// check explicitly for the last value40
if (res.back()[1] < time) return -1;