DIY: Interval Lists Intersection

Solve the interview question "Interval Lists Intersection" in this lesson.

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}}

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.