Given an array of intervals, find the minimum number of intervals to remove to make the rest non-overlapping.
With intervals = [[1,2],[2,3],[3,4],[1,3]]:
- [1,3] overlaps with [1,2] and [2,3].
- Remove [1,3]. Remaining: [[1,2],[2,3],[3,4]]. No overlaps.
- Remove interval.
With intervals = [[1,2],[1,2],[1,2]]:
- All identical. Keep one, remove two.
- Remove intervals.
With intervals = [[1,2],[2,3]]:
- [1,2] ends at 2, [2,3] starts at 2. No overlap (endpoints touching is OK).
- Remove intervals.
Constraints: intervals.length .