-
Notifications
You must be signed in to change notification settings - Fork 160
/
interval-list-intersections.md
31 lines (21 loc) · 1.59 KB
/
interval-list-intersections.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<p>Given two lists of <strong>closed</strong> intervals, each list of intervals is pairwise disjoint and in sorted order.</p>
<p>Return the intersection of these two interval lists.</p>
<p><em>(Formally, a closed interval <code>[a, b]</code> (with <code>a <= b</code>) denotes the set of real numbers <code>x</code> with <code>a <= x <= b</code>. The intersection of two closed intervals is a set of real numbers that is either empty, or can be represented as a closed interval. For example, the intersection of [1, 3] and [2, 4] is [2, 3].)</em></p>
<div>
<p> </p>
<p><strong>Example 1:</strong></p>
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2019/01/30/interval1.png" style="width: 506px; height: 140px;" /></strong></p>
<pre>
<strong>Input: </strong>A = <span id="example-input-1-1">[[0,2],[5,10],[13,23],[24,25]]</span>, B = <span id="example-input-1-2">[[1,5],[8,12],[15,24],[25,26]]</span>
<strong>Output: </strong><span id="example-output-1">[[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]]</span>
<strong>Reminder: </strong>The inputs and the desired output are lists of Interval objects, and not arrays or lists.
</pre>
<p> </p>
<p><strong>Note:</strong></p>
<ol>
<li><code>0 <= A.length < 1000</code></li>
<li><code>0 <= B.length < 1000</code></li>
<li><code>0 <= A[i].start, A[i].end, B[i].start, B[i].end < 10^9</code></li>
</ol>
<p><strong>NOTE:</strong> input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.</p>
</div>