Combine Two Vectors of Intervals (MLE) π
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.
Complete the function combineTwoVectorsOfIntervals in the editor π.
Returns
int[][]: The merged vector of intervals without any overlaps.
P.S. For original prompt, pls refer to source image. π
1Example 1
- 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.
Constraints
Limits and guarantees your solution can rely on.
An unknown myth for now