Interval List Intersections
Try to solve the Interval List Intersections problem.
We'll cover the following
Statement
Given two lists of intervalLista
and intervalListb
, return the intersection of the two interval lists.
Each interval in the lists has its own start and end time and is represented as [start, end]
. Specifically:
intervalLista[i] = [start
i
, end
i
]
intervalListb[j] = [start
j
, end
j
]
The intersection of two closed intervals i
and j
is either:
An empty set, if they do not overlap, or
A closed interval
[max(start
i
, start
j
), min(end
i
, end
j
)]
if they do overlap.
Also, each list of intervals is pairwise disjoint and in sorted order.
Constraints:
intervalLista.length
,intervalListb.length
intervalLista.length
intervalListb.length
start
i
end
i
end
i
start
i + 1
start
j
end
j
end
j
start[j + 1]
Examples
Create a free account to view this lesson.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy