Merge Intervals
Learn this problemProblem statement
Source note, June 26, 2026: Please ignore this question for now, as it may have source issues. If you still want to practice it, treat it as a rough draft rather than a reliable source-backed problem. I will investigate and clean it up later, but this may take a while. Sorry for the inconvenience, and thank you so much for your understanding. You are the best! 🐥
You are given an array of intervals where intervals[i] = [start_i, end_i].
Merge every pair of overlapping intervals and return an array of non-overlapping intervals that covers all intervals in the input.
Two intervals overlap if they share at least one common point. For example, [1, 2] and [3, 4] do not overlap, but [1, 2] and [2, 3] do overlap.
You may return the merged intervals in any order.
Function
mergeIntervals(intervals: int[][]) → int[][]Examples
Example 1
intervals = [[1, 3], [1, 5], [6, 7]]return = [[1, 5], [6, 7]]Example 2
intervals = [[1, 2], [2, 3]]return = [[1, 3]]Constraints
1 <= intervals.length <= 1000intervals[i].length == 20 <= start_i <= end_i <= 1000
More Roblox problems
- Most Frequent Call Stack Per ThreadPHONE SCREEN · Seen Jul 2026
- Maximum Number of Balls in a BoxPHONE SCREEN · Seen Jun 2026
- Meeting Rooms IIPHONE SCREEN · Seen Jun 2026
- Most Frequent Call Path From Function Trace LogsPHONE SCREEN · Seen Jun 2026
- Single-Threaded CPUPHONE SCREEN · Seen Jun 2026
- Sliding Window: Target Containment and Most-Repeated WindowPHONE SCREEN · Seen Jun 2026
- Topological Sort with Secondary OrderingPHONE SCREEN · Seen Jun 2026
- Implement a Rate LimiterPHONE SCREEN · Seen May 2026