Statement
Given an array of intervals where intervals[i]
contains the half-open intervalAn interval that contains only one of its boundary elements. The “(” parenthesis denotes the exclusion of the starting point. The “]” bracket denotes the inclusion of the ending point., (starti,endi], your task is to find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
Note: Two intervals (a,b] and (c,d] are considered overlapping if there exists a value x such that a<x≤b and c<x≤d. In other words, if there is any point within both intervals (excluding their starting points) where both intervals have values, they are considered overlapping. For example, the intervals (7,11] and (10,12] are overlapping, whereas the intervals (2,4] and (4,5] are non-overlapping.
Constraints:
1≤intervals.length
≤103
intervals[i].length
==2
−5×104≤starti<endi≤5×104
Examples