要求:rt
思路:
class Solution {
public:
bool static cmp(vector<int> &a,vector<int> &b){
return a[0]==b[0]?a[1]<b[1]:a[0]<b[0];
}
vector<vector<int>> merge(vector<vector<int>>& intervals) {
vector<vector<int>> v;
int n=intervals.size();
sort(intervals.begin(),intervals.end(),cmp);
v.push_back(intervals[0]);
for(int i=1;i<n;++i){
if(v.back()[1]<intervals[i][0])
v.push_back(intervals[i]);
else if(v.back()[1]<intervals[i][1])v.back()[1]=intervals[i][1];
}
return v;
}
};