Practice/Meta/Leetcode 986. Interval List Intersections
CodingMust
You are given two lists of closed intervals. Each list is sorted by start time and contains non-overlapping intervals (pairwise disjoint). Your task is to find all the intersections between intervals from the first list and intervals from the second list.
An intersection occurs when two intervals share at least one common point. For example, intervals [3, 7] and [5, 9] intersect at [5, 7].
Return a sorted list of all intersection intervals.
Example 1:
` 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]]
Explanation:
Example 2:
` Input: firstList = [[1, 3], [5, 7]] secondList = [[4, 4], [8, 10]]
Output: []
Explanation: No intervals overlap between the two lists `
Example 3:
` Input: firstList = [[1, 10]] secondList = [[2, 3], [5, 6], [8, 9]]
Output: [[2, 3], [5, 6], [8, 9]]
Explanation: The single interval [1,10] contains all intervals from the second list `