Merge Meeting Intervals
Updated
Problem statement
You are given an unsorted array of meeting times called intervals. Merge overlapping meetings into the longest continuous periods of occupied time.
For this exercise, assume each interval [start, end] represents the half-open span [start, end), with start < end. Also merge periods whose endpoints touch: [1,3) and [3,5) produce [1,5), because their union has no gap.
Return the merged periods from earliest start to latest start. Merge as far as possible, so consecutive returned periods satisfy previousEnd < nextStart. Repeated intervals and intervals fully inside another interval do not add separate results. An empty input returns an empty array.
This is an occupied-time summary, not room allocation: do not discard, shorten, reschedule or cancel any meeting. Do not change the input array.
Function
mergeMeetingIntervals(intervals: int[][]) → int[][]Examples
Example 1
intervals = [[5,7],[1,4],[3,6],[10,12]]return = [[1,7],[10,12]]The first three intervals connect through overlaps and cover [1,7). The span [10,12) remains separate because there is a gap.
Example 2
intervals = [[0,2],[2,5]]return = [[0,5]]The intervals touch at 2. Their union is the single half-open span [0,5).
Example 3
intervals = []return = []There is no occupied time to summarize.
Constraints
0 <= intervals.length <= 200.- Each interval contains exactly two signed-32-bit integers with
-2147483648 <= start < end <= 2147483647.
More Uber Phone Screen questions
- Worst-Performing Ads by CTR in a Campaign TreePHONE SCREEN · Seen Nov 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Max Points on a LinePHONE SCREEN · Seen Oct 2026
- Convex Function MinimizationPHONE SCREEN · Seen Oct 2026
- Meeting Rooms IIPHONE SCREEN · Seen Oct 2026
- Minimum Meeting Rooms with AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Find Robots by Blocker DistancesPHONE SCREEN · Seen Oct 2026
- Sliding-Window Rate LimiterPHONE SCREEN · Seen Oct 2026
- Count Connected IslandsPHONE SCREEN · Seen Sep 2026
- Dynamic Island CountsPHONE SCREEN · Seen Sep 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
- Merge IntervalsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Merge Overlapping IntervalsFurtherAI · PHONE SCREEN
- Peak Resource Usage Across Weighted IntervalsTekion · PHONE SCREENTekion interview questions
- Merge Overlapping IntervalsFox Corporation · PHONE SCREEN