Posted on

Description

Submission

class Solution {
public:
    int removeCoveredIntervals(vector<vector<int>>& intervals) {
        sort(intervals.begin(), intervals.end(), [](auto& v1, auto& v2) {
            return (v1[1] < v2[1] || (v1[1] == v2[1] && v1[0] > v2[0]));
        });
        
        int n = intervals.size();
        
        int ret = n;
        for(int i = 0; i < n; ++i) {
            for(int j = i + 1; j < n; ++j) {
                if(intervals[j][0] <= intervals[i][0]) {
                    ret--;
                    break;
                }
                
            }
        }
        return ret;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *