Merge Intervals
Updated
Problem statement
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]]The intervals [1, 3] and [1, 5] overlap, so they merge into [1, 5]. The interval [6, 7] does not overlap with that merged interval.
Example 2
intervals = [[1, 2], [2, 3]]return = [[1, 3]]The two intervals share point 2, so they overlap and merge into [1, 3].
Constraints
1 <= intervals.length <= 1000intervals[i].length == 20 <= start_i <= end_i <= 1000
More Roblox Phone Screen questions
- Most Frequent Call Path From Function Trace LogsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
- Rate Limit by Multiple Request FieldsPHONE SCREEN · Seen Oct 2026
- Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Time-Aware Search AutocompletePHONE SCREEN · Seen Oct 2026
- Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Closest Binary Search Tree Value — Base PracticePHONE SCREEN · Seen Jun 2026
Similar questions at other companies
- Merge IntervalsApple · OA · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
- Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
- Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
- Meeting Rooms IIByteDance · PHONE SCREENByteDance interview questions
- Majority Labels over Audio IntervalsNooks · PHONE SCREEN
- Meeting Rooms IIUber · PHONE SCREENUber interview questions
- Merge IntervalsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Merge Overlapping IntervalsFurtherAI · PHONE SCREEN
- Peak Resource Usage Across Weighted IntervalsTekion · PHONE SCREENTekion interview questions
Roblox interview experiences
- Roblox OA: What It Tests (2026)
- Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
- Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
- Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
- Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
- Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)