Remove Covered Intervals Problem

Remove Covered Intervals Problem — ExecCode Easy DSA Practice

Solve the Remove Covered Intervals problem on ExecCode. Free online easy DSA practice in Intervals. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given an array of intervals, an interval [a, b) is covered by another interval [c, d) when c ≤ a and b ≤ d. Remove all intervals that are covered by some other interval in the list, and return the number of remaining intervals.

Examples

Input intervals = [[1, 4], [3, 6], [2, 8]]; Output 2. Input intervals = [[1, 4], [2, 3]]; Output 1. Input intervals = [[0, 10], [5, 12]]; Output 2

Constraints

1 ≤ intervals.length ≤ 1000 intervals[i].length == 2 0 ≤ starti < endi ≤ 5×10⁴ all the given intervals are unique

Practice Remove Covered Intervals free on ExecCode. Browse DSA problems, topic map, and placement guides.