Non-overlapping Intervals

Given an array of intervals `intervals`, return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. **Pattern focus:** Greedy by End Time. Optimize for the largest set of non-overlapping intervals.

Examples

Example 1:

Input:

intervals = [[1,2],[2,3],[3,4],[1,3]]

Output:

1

Explanation:

Remove [1,3] to avoid overlaps (output 1).

Example 2:

Input:

intervals = [[1,2],[1,2],[1,2]]

Output:

2

Explanation:

Remove 2 of the 3 identical intervals to avoid overlaps.

Loading...
Non-overlapping Intervals - Intervals