Problem
You get a list intervals in no special order. Each item [start, end] is one interval.
Two intervals overlap when they share at least one point. For example, [2, 5] and [5, 7] overlap at the point 5.
Merge the intervals that overlap, and continue until no two intervals overlap. When you merge intervals, you replace them with one interval from their smallest start to their largest end.
Return the result in ascending order of start.
Example 1
- Input:
- intervals = [[8,10],[1,3],[2,5],[12,14],[9,11]]
- Output:
- [[1,5],[8,11],[12,14]]
- Explanation:
- The intervals
[1, 3]and[2, 5]merge into[1, 5]. The intervals[8, 10]and[9, 11]merge into[8, 11].
Example 2
- Input:
- intervals = [[3,4],[4,9]]
- Output:
- [[3,9]]
- Explanation:
- The two intervals share the point 4, so they merge.
Example 3
- Input:
- intervals = [[1,10],[2,3],[4,5]]
- Output:
- [[1,10]]
- Explanation:
- The first interval contains the other two intervals.
Constraints
- 1 <= intervals.length <= 10^4
- intervals[i].length == 2
- 0 <= start <= end <= 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.
- Sort Colors
Coding · Array · Bubble Sort · Quicksort
- Accounts Merge
Coding · Array · Breadth-First Search · Depth-First Search
- Merge Sorted Array
Coding · Array · Sorting · Two Pointers
- Non-overlapping Intervals
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 · 12 records
Amazon
Leetcode 56. Merge Intervals
Reported Sep 30, 2026 · 9 source reports
JUNIOR, MID_LEVEL, SENIOR
Source snapshot: Nov 12, 2026
View sourceAntithesis
Leetcode 56. Merge Intervals
Reported Nov 19, 2025 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceApple
Leetcode 56. Merge Intervals
Reported Oct 1, 2026 · 3 source reports
MID_LEVEL, SENIOR
Source snapshot: Nov 12, 2026
View sourceAtlassian
Leetcode 56. Merge Intervals
Reported Oct 16, 2026 · 2 source reports
PRINCIPAL, STAFF
Source snapshot: Nov 12, 2026
View source