vector<vector<int>>merge(vector<vector<int>>& intervals){// 排序sort(intervals.begin(), intervals.end());// 合并区间
vector<vector<int>> ret;int left = intervals[0][0], right = intervals[0][1];for(int i =0; i < intervals.size(); i++){int a = intervals[i][0], b = intervals[i][1];if(a <= right)// 有重叠{
right =max(right, b);}else// 无重叠{
ret.push_back({left, right});
left = a;
right = b;}}// 最后一个区间
ret.push_back({left, right});return ret;}
interaseOverlapIntervals(vector<vector<int>>& intervals){// 排序sort(intervals.begin(), intervals.end());// 移除区间int ret =0;int left = intervals[0][0], right = intervals[0][1];for(int i =1; i < intervals.size(); i++){int a = intervals[i][0], b = intervals[i][1];if(a < right)// 有重叠{
ret++;// DELETE
right =min(right, b);// 贪心, 删除右端点较大的区间}else// 无重叠{
right = b;}}return ret;}
intfindMinArrowShots(vector<vector<int>>& points){// 排序sort(points.begin(), points.end());// 求互相重叠区间的数量int right = points[0][1];int ret =1;for(int i =1; i < points.size(); i++){int a = points[i][0], b = points[i][1];if(a <= right)// 有重叠{
right =min(right, b);}else// 无重叠{
ret++;
right = b;}}return ret;}