vector<vector<int>> merge(vector<vector<int>>& intervals) {
vector<vector<int>> res;
if(intervals.empty()) return res;
sort(intervals.begin(),intervals.end());
for(auto num:intervals){
if(res.empty() || res.back()[1]<num[0])
res.push_back(num);
else
res.back()[1] = max(res.back()[1],num[1]);
}
return res;
}
56. 合并区间/C++
最新推荐文章于 2024-07-22 16:48:28 发布