435. Non Overlapping Intervals

Practice Non Overlapping Intervals for free on NudgeCode: Medium, Greedy pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Return the smallest number of intervals you must remove from intervals so that the rest don't overlap. Intervals that only touch at an end point, like [1,2] and [2,3], do not overlap.

Example

intervals = [[1,2],[2,3],[3,4],[1,3]]  ->  1
intervals = [[1,2],[1,2],[1,2]]        ->  2

Constraints