代码
class Solution {
public:
vector<vector<int>> insert(vector<vector<int>>& a, vector<int>& b) {
vector<vector<int>> ans;
int k = 0;
while(k < a.size() && a[k][1] < b[0]) ans.push_back(a[k++]);
if (k < a.size()) {
b[0] = min(b[0], a[k][0]);
while (k < a.size() && a[k][0] <= b[1]) b[1] = max(b[1], a[k++][1]);
}
ans.push_back(b);
while (k < a.size()) ans.push_back(a[k++]);
return ans;
}
};