986. Interval List Intersections Medium
1/**
2 * [986] Interval List Intersections
3 *
4 * You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of intervals is pairwise disjoint and in sorted order.
5 * Return the intersection of these two interval lists.
6 * A closed interval [a, b] (with a <= b) denotes the set of real numbers x with a <= x <= b.
7 * The intersection of two closed intervals is a set of real numbers that are either empty or represented as a closed interval. For example, the intersection of [1, 3] and [2, 4] is [2, 3].
8 *
9 * Example 1:
10 * <img alt="" src="https://assets.leetcode.com/uploads/2019/01/30/interval1.png" style="width: 700px; height: 194px;" />
11 * Input: firstList = [[0,2],[5,10],[13,23],[24,25]], secondList = [[1,5],[8,12],[15,24],[25,26]]
12 * Output: [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]]
13 *
14 * Example 2:
15 *
16 * Input: firstList = [[1,3],[5,9]], secondList = []
17 * Output: []
18 *
19 *
20 * Constraints:
21 *
22 * 0 <= firstList.length, secondList.length <= 1000
23 * firstList.length + secondList.length >= 1
24 * 0 <= starti < endi <= 10^9
25 * endi < starti+1
26 * 0 <= startj < endj <= 10^9
27 * endj < startj+1
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/interval-list-intersections/
33// discuss: https://leetcode.com/problems/interval-list-intersections/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn interval_intersection(first_list: Vec<Vec<i32>>, second_list: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
39 vec![]
40 }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_986() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.