Non-overlapping Intervals
Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.

30:00

Non-overlapping Intervals
medium
Topics
Companies

Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.

Example 1:
Input: [[1,2],[2,3],[3,4],[1,3]]
Output: 1
Constraints:
  • 1intervals.length1051 \leq \text{intervals.length} \leq 10^5

  • intervals[i].length==2\text{intervals}[i].\text{length} == 2

  • 5×104starti<endi5×104-5 \times 10^4 \leq \text{start}_i < \text{end}_i \leq 5 \times 10^4

Input
arr =[[1,2],[2,3],[3,4],[1,3]]

Start

[1,2]
[2,3]
[3,4]
[1,3]
Prev End
-Inf
Removed Count
0
Variables
No variables to display
DepthFunction Call
Stack empty
0/14