986. 区间列表的交集 题解
https://leetcode-cn.com/problems/interval-list-intersections/
class Solution { public: vector<vector<int>> intervalIntersection(vector<vector<int>>& firstList, vector<vector<int>>& secondList) { vector<vector<int>> ans; int i=0,j=0; int left=0,right=0; while(i<firstList.size()&&j<secondList.size()){ left=max(firstList[i][0],secondList[j][0]); right=min(firstList[i][1],secondList[j][1]); if(left<=right){ ans.push_back({left,right}); } if(firstList[i][1]<secondList[j][1]){ i++; }else{ j++; } } return ans; } };