Problem
You get a list intervals. Each item [start, end] is one interval, and start is less than end.
In this problem, two intervals overlap when each one starts before the other one ends. Intervals that only touch do not overlap. For example, [1, 3] and [3, 5] do not overlap.
Return the smallest number of intervals that you must remove, so that no two of the other intervals overlap.
Example 1
- Input:
- intervals = [[1,4],[2,3],[3,6],[5,7]]
- Output:
- 2
- Explanation:
- Remove
[1, 4]and[5, 7]. The intervals[2, 3]and[3, 6]only touch, so they do not overlap.
Example 2
- Input:
- intervals = [[0,5],[0,5],[0,5]]
- Output:
- 2
- Explanation:
- The three intervals are the same, so you can keep only one of them.
Example 3
- Input:
- intervals = [[4,5],[1,2],[2,4]]
- Output:
- 0
- Explanation:
- The intervals only touch at 2 and at 4.
Constraints
- 1 <= intervals.length <= 10^5
- intervals[i].length == 2
- -5 * 10^4 <= start < end <= 5 * 10^4
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Two Best Non-Overlapping Events
Coding · Array · Binary Search · Dynamic Programming
- Advantage Shuffle
Coding · Array · Greedy · Sorting
- Best Time to Buy and Sell Stock II
Coding · Array · Dynamic Programming · Greedy
- Jump Game
Coding · Array · Dynamic Programming · Greedy
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 2 records
Amazon
Leetcode 435. Non-overlapping Intervals
Reported Sep 3, 2025 · 2 source reports
JUNIOR, MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceDocusign
Leetcode 435. Non-overlapping Intervals
Reported Jul 1, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 2 records
Grammarly
Non-overlapping Intervals
Reported date not specified · Source window: 3mo
Source snapshot: Oct 20, 2026
Source frequency score: 90.1. This is not an interview probability.
View sourceGrammarly
Non-overlapping Intervals