The list intervals holds time slots [start, end]. Remove as few slots as you can so that no two of the remaining slots overlap. Return how many slots you removed.
Two slots that only touch at one point, like [1,2] and [2,3], do not overlap.
Examples
Example 1:
Input: intervals = [[1,5],[2,3],[4,6],[7,9]]
Output: 1
Explanation: Remove [1,5]. Then [2,3], [4,6] and [7,9] do not overlap. One removal is enough.
Example 2:
Input: intervals = [[3,4],[3,4],[3,4],[3,4]]
Output: 3
Explanation: All four slots are the same. Keep one and remove the other three.
Example 3:
Input: intervals = [[1,2],[2,4],[5,6]]
Output: 0
Explanation: The slots only touch at the end points, so nothing needs to be removed.