Combine Two Vectors of Intervals (MLE) π
Updated
Problem statement
Imagine you have two vectors of intervals, labeled as X and Y, each representing a series of segments along a path. In vector X, there are no overlapping segments, and the same goes for vector Y. Your task is to merge these two vector into a single vector, ensuring that there are no overlaps in the resulting segments. However, you're asked to devise a highly efficient solution that outperforms naive methods.
Function
combineTwoVectorsOfIntervals(X: int[][], Y: int[][]) β int[][]
Complete the function combineTwoVectorsOfIntervals in the editor π.
Returns
int[][]: The merged vector of intervals without any overlaps.
Examples
Example 1
X = [[1,5], [10,14], [16,18]]Y = [[2,6], [8,10], [11,20]]return = [[1,6], [8,20]]The intervals from list X and list Y are merged and the overlapping intervals are combined to produce the following output:
- The intervals [1,5] and [2,6] overlap and can be merged into [1,6].
- The intervals [10,14] and [11,20] overlap with [8,10], and all can be merged into [8,20].
- The interval [16,18] is within the bounds of [11,20] and is therefore already covered by it.
The resulting merged list of intervals with no overlaps is [[1,6], [8,20]].
Constraints
An unknown myth for now
More Meta Phone Screen questions
- Mutual-Friend RecommendationsPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
- Best Time to Buy and Sell StockPHONE SCREEN Β· Seen Nov 2026
- First Element Greater Than KPHONE SCREEN Β· Seen Nov 2026
- Count Events in Rolling Minute WindowsPHONE SCREEN Β· Seen Oct 2026
- Valid Word AbbreviationPHONE SCREEN Β· Seen Oct 2026
- Shortest Path in a Binary MatrixPHONE SCREEN Β· Seen Sep 2026
- Deterministic K-Means AssignmentsPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Sep 2026
- Multi-Head Attention Forward PassPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Sep 2026
- Values Exclusive to the Current UserPHONE SCREEN Β· Seen Sep 2026
- First Bad Version in a Monotone ArrayPHONE SCREEN Β· Seen Sep 2026
Similar questions at other companies
- Minimum Rooms for Meeting IntervalsOYO Rooms Β· PHONE SCREEN
- Meeting Rooms IIUber Β· PHONE SCREENUber interview questions
- Maximum Concurrent ProcessesMorgan Stanley Β· OA Β· ONSITE INTERVIEWMorgan Stanley interview questions
- Meeting Rooms IIAmazon Β· PHONE SCREEN Β· ONSITE INTERVIEW
- Common Camera Motion IntervalsVerkada Β· PHONE SCREENVerkada interview questions
- Intersect Two Sorted Interval ListsByteDance Β· PHONE SCREENByteDance interview questions
- Meeting Rooms IIWalmart Β· PHONE SCREENWalmart interview questions
- Intersect Two Interval ListsSuperhuman Β· PHONE SCREENSuperhuman interview questions
- Find Shared Camera Activity PeriodsServal Β· PHONE SCREEN
- Interval List IntersectionsGoogle Β· ONSITE INTERVIEWGoogle interview questions
Meta interview experiences
- Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
- Meta Business Support Engineer Phone Screen: 1 Experience
- Meta Software Engineer Onsite Questions: 3 Experiences
- Meta AI Native Engineer OA and Onsite: 1 Experience
- Meta AI-Native Coding Interview: 3 Experiences
- Meta Production Engineer Intern Questions: 6 Experiences