# LeetCode435 — 预定会议问题()-其他

## LeetCode435 — 预定会议问题()

### 1. 题目描述

``````|_________|                  区间a
|___|                      区间b
|__|                  区间c
|______|         区间d
``````

``sort``
``cmp``

### 3. 代码

``````class Solution {
public:
int eraseOverlapIntervals(vector<vector<int>>& intervals) {
sort(intervals.begin(), intervals.end(), [&](auto &x, auto &y){
if(x[1] == y[1])    return x[0] < y[0];
return x[1] < y[1];
});
int res = 0;
int right = -2e9;
for(auto &x : intervals) {
if(x[0] >= right) {
right = x[1];
res ++ ;
}
}
return intervals.size() - res;
}
};
``````
————————

### 1. 题目描述

``````|_________|                  区间a
|___|                      区间b
|__|                  区间c
|______|         区间d
``````

``sort``
``cmp``

### 3. 代码

``````class Solution {
public:
int eraseOverlapIntervals(vector<vector<int>>& intervals) {
sort(intervals.begin(), intervals.end(), [&](auto &x, auto &y){
if(x[1] == y[1])    return x[0] < y[0];
return x[1] < y[1];
});
int res = 0;
int right = -2e9;
for(auto &x : intervals) {
if(x[0] >= right) {
right = x[1];
res ++ ;
}
}
return intervals.size() - res;
}
};
``````