Skip to content

Commit 516d1a8

Browse files
committed
986
1 parent 8e44b53 commit 516d1a8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

986.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution {
2+
public:
3+
vector<vector<int>> intervalIntersection(vector<vector<int>>& A, vector<vector<int>>& B) {
4+
vector<vector<int>>C;
5+
int i=0;
6+
int j=0;
7+
while( i<A.size() && j<B.size() ){
8+
int less=max(A[i][0], B[j][0] );
9+
int more=min(A[i][1], B[j][1] );
10+
if(less<=more){
11+
vector<int>V;
12+
V.push_back(less);
13+
V.push_back(more);
14+
C.push_back(V);
15+
}
16+
if(A[i][1]<B[j][1]){
17+
i++;
18+
}
19+
else {
20+
j++;
21+
}
22+
}
23+
return C;
24+
25+
}
26+
};

0 commit comments

Comments
 (0)