Given an array of intervals where intervals[i] = [start_i, end_i]
, find the minimum number of intervals to remove to make the remaining intervals non-overlapping.
Rules:
Constraints:
Examples:
// Example 1:
console.log(
eraseOverlapIntervals([
[1, 2],
[2, 4],
[1, 4],
]),
);
// Output: 1
// Explanation: Remove [1,4] to make non-overlapping
// Example 2:
console.log(
eraseOverlapIntervals([
[1, 2],
[2, 4],
]),
);
// Output: 0
// Explanation: Already non-overlapping