Interval List Intersections Problem
Interval List Intersections Problem — ExecCode Medium DSA Practice
Solve the Interval List Intersections problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You are given two lists of closed intervals, firstList and secondList, where each list is pairwise disjoint and sorted by start time. Return the list of intervals representing the intersection of the two interval lists.
Examples
Input firstList = [[0, 2], [5, 10], [13, 23], [24, 25]], secondList = [[1, 5], [8, 12], [15, 24], [25, 26]]; Output [[1, 2], [5, 5], [8, 10], [15, 23], [24, 24], [25, 25]]. Input firstList = [[1, 3], [5, 9]], secondList = []; Output []. Input firstList = [[1, 7]], secondList = [[3, 10]]; Output [[3, 7]]
Constraints
0 ≤ firstList.length, secondList.length ≤ 1000 firstList.length + secondList.length ≥ 1 0 ≤ starti < endi ≤ 10⁹ endi < starti+1 for consecutive intervals in each list
Practice Interval List Intersections free on ExecCode. Browse DSA problems, topic map, and placement guides.