You are given a collection of intervals.
Your task is to find the minimum number of intervals that must be removed so that the remaining intervals are non-overlapping.
Note that:
interval, its end point is always greater than its start point.intervals [a, b] and [c, d] are considered non-overlapping if b <= c or d <= a. For example, [1,2] and [2,3] are non-overlapping.Return the minimum number of intervals to remove.
[ [1, 3], [3, 5] ]
0
The intervals [1,3] and [3,5] do not overlap, so no intervals need to be removed.
[ [1, 3], [3, 5], [2, 4] ]
1
The interval [2,4] overlaps with both [1,3] and [3,5]. Removing [2,4] leaves the non-overlapping intervals [1,3] and [3,5].
[ [1, 2], [1, 3] ]
1
The intervals [1,2] and [1,3] overlap. Removing either one will leave a non-overlapping interval.
[ [1, 3], [3, 5] ]
0