Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
30:00
Java
Merge Intervals
medium
Topics
Companies
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
Example 1:
Input: [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Constraints:
1≤intervals.length≤104
intervals[i].length==2
0≤starti≤endi≤104
Input
arr =[[1,3],[2,6],[8,10],[15,18]]
Start
[1,3]
[2,6]
[8,10]
[15,18]
Prev End
-Inf
Removed Count
0
Variables
No variables to display
DepthFunction Call
Stack empty
0/12
Asked in these interview guides
Company guides that list this problem among their sample questions.