1288. Remove Covered Intervals Medium

@problem@discussion
#Array#Sorting



1/**
2 * [1288] Remove Covered Intervals
3 *
4 * Given an array intervals where intervals[i] = [li, ri] represent the interval [li, ri), remove all intervals that are covered by another interval in the list.
5 * The interval [a, b) is covered by the interval [c, d) if and only if c <= a and b <= d.
6 * Return the number of remaining intervals.
7 *  
8 * Example 1:
9 * 
10 * Input: intervals = [[1,4],[3,6],[2,8]]
11 * Output: 2
12 * Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
13 * 
14 * Example 2:
15 * 
16 * Input: intervals = [[1,4],[2,3]]
17 * Output: 1
18 * 
19 *  
20 * Constraints:
21 * 
22 * 	1 <= intervals.length <= 1000
23 * 	intervals[i].length == 2
24 * 	0 <= li < ri <= 10^5
25 * 	All the given intervals are unique.
26 * 
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/remove-covered-intervals/
31// discuss: https://leetcode.com/problems/remove-covered-intervals/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36    pub fn remove_covered_intervals(intervals: Vec<Vec<i32>>) -> i32 {
37        0
38    }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45    use super::*;
46
47    #[test]
48    fn test_1288() {
49    }
50}
51


Back
© 2025 bowen.ge All Rights Reserved.