Non-overlapping Intervals
Medium
LC #435
intervalsgreedysortingNot attempted yet
Given intervals where each is [start, end], return
the minimum number of intervals to remove so that the
remaining ones don't overlap.
Intervals that only touch, like [1,2] and [2,3],
do not overlap.
Example 1
Input: intervals = [[1,2],[2,3],[3,4],[1,3]]
Output: 1
Remove [1,3].
Example 2
Input: intervals = [[1,2],[1,2],[1,2]]
Output: 2
Example 3
Input: intervals = [[1,2],[2,3]]
Output: 0
Constraints
- 1 <= intervals.length <= 10^5
- -10^5 <= start < end <= 10^5