medium

Non-overlapping Intervals

Given a list of half-open intervals, return the minimum number you must remove so that the remaining intervals do not overlap. Intervals that merely touch at an endpoint do not overlap.

Constraints
  • 1 ≤ intervals.length ≤ 10^5
  • -5 · 10^4 ≤ start < end ≤ 5 · 10^4
Examples
in: intervals = [[1,2],[2,3],[3,4],[1,3]]
out: 1
Remove [1,3].

Code it yourself

Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?

Choose an approach to check your pattern recognition, or reveal the discussion when you need help.