Problem
You get a list intervals. Each item [start, end] is one interval. The list is in ascending order of start, and no two intervals in it overlap.
Two intervals overlap when they share at least one point. For example, [1, 3] and [3, 5] overlap at the point 3.
You also get one more interval newInterval. Add it to the list. Then merge the intervals that overlap, so that no two intervals overlap. When you merge intervals, you replace them with one interval from their smallest start to their largest end.
Return the new list in ascending order of start.
Example 1
- Input:
- intervals = [[1,2],[4,6],[8,10],[13,15]], newInterval = [5,9]
- Output:
- [[1,2],[4,10],[13,15]]
- Explanation:
- The new interval overlaps
[4, 6]and[8, 10]. These three intervals merge into[4, 10].
Example 2
- Input:
- intervals = [[2,4]], newInterval = [6,7]
- Output:
- [[2,4],[6,7]]
- Explanation:
- The new interval does not overlap
[2, 4], so the list only gets one more item.
Example 3
- Input:
- intervals = [], newInterval = [3,8]
- Output:
- [[3,8]]
Constraints
- 0 <= intervals.length <= 10^4
- intervals[i].length == 2
- 0 <= start <= end <= 10^5
- intervals is in ascending order of start
- No two items of intervals overlap
- newInterval.length == 2
- 0 <= newInterval[0] <= newInterval[1] <= 10^5
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 3 records
Fanduel
Leetcode 57. Insert Interval
Reported Jan 8, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceGoogle
Leetcode 57. Insert Interval
Reported Aug 1, 2024 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 57. Insert Interval
Reported Apr 30, 2025 · 5 source reports
MID_LEVEL, SENIOR, STAFF
Source snapshot: Nov 12, 2026
View source