Practice/Google/Leetcode 1288. Remove Covered Intervals
CodingMust
You are given a collection of intervals where each interval is represented as a pair of integers [start, end]. An interval [a, b] is considered covered by another interval [c, d] if and only if c <= a and b <= d.
Your task is to remove all covered intervals from the collection and return the count of intervals that remain after removal.
Example 1:
Input: intervals = [[1,4],[3,6],[2,8]] Output: 2 Explanation: The interval [3,6] is covered by [2,8] because 2 <= 3 and 6 <= 8. After removing [3,6], we have 2 intervals remaining: [1,4] and [2,8].
Example 2:
Input: intervals = [[1,4],[2,3]] Output: 1 Explanation: The interval [2,3] is covered by [1,4] because 1 <= 2 and 3 <= 4. After removing [2,3], only 1 interval remains.
Example 3:
Input: intervals = [[1,2],[1,3],[1,4]] Output: 1 Explanation: [1,2] is covered by [1,3], and [1,3] is covered by [1,4]. Only [1,4] remains, giving us 1 interval.