1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| #include<vector>
#include<algorithm>
using namespace std;
class Solution { public: int eraseOverlapIntervals(vector<vector<int>>& intervals) { if(intervals.empty()){ return 0; } sort(intervals.begin(), intervals.end(), { return a[1] < b[1]; }); int res = 0, prev = intervals0; for (int i = 1; i < intervals.size();i++){ if(intervalsi<prev){ res++; }else{ prev = intervalsi; } } return res; } };
|