Description
Solutions
Combine Two Vectors of Intervals (MLE) π
πRELATED PROBLEMS
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 Description
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. π
Example 1:
Input: X = [[1,5], [10,14], [16,18]], Y = [[2,6], [8,10], [11,20]]
Output: [[1,6], [8,20]]
Explanation:The intervals from list X and list Y are merged and the overlapping intervals are combined to produce the following output:The resulting merged list of intervals with no overlaps is [[1,6], [8,20]]. (Provided by Groot with π«Ά from the west coast. PLS dont hesitate to correct me if you find anything wrong. I am always on the discord serva π΅)
- 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:
An unknown myth for now

Related Problems
Testcase
Result
Case 1
input:
output: