Given an array of intervals where intervals[i] = [start_i, end_i], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
Note: intervals that share only an endpoint (e.g., [1,2] and [2,3]) are considered non-overlapping.
Input: intervals = [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation: Remove [1,3] and the remaining intervals are non-overlapping.
Input: intervals = [[1,2],[1,2],[1,2]] Output: 2 Explanation: Two of the three identical intervals must be removed.
Input: intervals = [[1,2],[2,3]] Output: 0 Explanation: They share only an endpoint, so no removal is needed.
1 <= intervals.length <= 10^5intervals[i].length == 2-5 * 10^4 <= start_i < end_i <= 5 * 10^4intervals = [[1, 2], [2, 3], [3, 4], [1, 3]]