Skip to content

Commit 30f1206

Browse files
committed
leetcode
1 parent de892fa commit 30f1206

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
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)