leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1288.cpp (504B)


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