1288.cpp (504B)
1 class Solution { 2 public: 3 int removeCoveredIntervals(vector<vector<int>> &intervals) const { 4 const int n = size(intervals); 5 6 sort(begin(intervals), end(intervals), 7 [](const auto &a, const auto &b) { return a[0] != b[0] ? a[0] < b[0] : a[1] > b[1]; }); 8 9 int res = 0, right = 0; 10 for (int i = 0; i < n; i++) { 11 if (intervals[i][1] <= right) continue; 12 right = intervals[i][1]; 13 res++; 14 } 15 return res; 16 } 17 };