DIY: Interval Lists Intersection
Solve the interview question "Interval Lists Intersection" in this lesson.
We'll cover the following...
Problem statement
In this problem, you are provided with two lists of intervals. Each list contains a disjoint and intervals. Your job is to find the intersection of these lists of intervals.
Input
The input is two lists of intervals. Each list contains nested lists that have two integers representing the starting and ending points of the interval. The following is an example input:
{{1, 3}, {5, 6}, {7, 9}}
{{2, 4}, {6, 7}, {8, 10}}
Output
The output is a list that contains the intervals’ intersection. The following is an example output:
{{2, 3}, {8, 9}}
Access this course and 1400+ top-rated courses and projects.