Count Intervals Not Contained in Another. Each pair[l,r] denotes the half-open interval[l,r). Remove an interval[a,b) if some other input interval[c,d) has c<=a and b<=d.
### Problem
Each pair [l,r] denotes the half-open interval [l,r). Remove an interval [a,b) if some other input interval [c,d) has c<=a and b<=d. Return how many remain. All input intervals are unique.
```cpp
class Solution {
public:
int removeCoveredIntervals(vector<vector<int>>& intervals);
};
```
### Examples
**Example 1:**
```text
Input: intervals = [[0,5],[0,3],[2,6]]
Output: 2
Explanation: [0,3) is covered by[0,5); neither of the other two covers the other.
```
**Example 2:**
```text
Input: intervals = [[1,2],[2,3]]
Output: 2
Explanation: Touching endpoints do not make either interval contain the other.
```
### Constraints
- There are 1 to 1000 distinct intervals, each a pair of integers.
- Every interval satisfies `0 <= l < r <= 100000`.
### Contract considerations
Return only the count, and retain half-open interval semantics.
```hint Read the boundary condition
Can intervals sharing one endpoint still cover one another, and is the result a count or a list?
```
### Boundary reminders
Return only the count, and retain half-open interval semantics.
Overview: Count Intervals Not Contained in Another. Each pair[l,r] denotes the half-open interval[l,r). Remove an interval[a,b) if some other input interval[c,d) has c<=a and b<=d.
Each pair [l,r] denotes the half-open interval [l,r). Remove an interval [a,b) if some other input interval [c,d) has c<=a and b<=d. Return how many remain. All input intervals are unique.
class Solution {
public:
int removeCoveredIntervals(vector<vector<int>>& intervals);
};
Examples
Example 1:
Input: intervals = [[0,5],[0,3],[2,6]]
Output: 2
Explanation: [0,3) is covered by[0,5); neither of the other two covers the other.
Example 2:
Input: intervals = [[1,2],[2,3]]
Output: 2
Explanation: Touching endpoints do not make either interval contain the other.
Constraints
There are 1 to 1000 distinct intervals, each a pair of integers.
Every interval satisfies
0 <= l < r <= 100000
.
Contract considerations
Return only the count, and retain half-open interval semantics.
Boundary reminders
Return only the count, and retain half-open interval semantics.