class Solution {

public:

```
int eraseOverlapIntervals(vector<Interval>& intervals) {
int len=intervals.size();
if(len<=1) return 0;
sort(intervals.begin(),intervals.end(),[](Interval a,Interval b){
return a.end<b.end; });
int sum=1,r=intervals[0].end;
for(int x=1;x<len;x++)
if(intervals[x].start>=r) sum++,r=intervals[x].end;
return len-sum;
}
```

};