|
| 1 | +<h2><a href="https://leetcode.com/problems/set-intersection-size-at-least-two">759. Set Intersection Size At Least Two</a></h2><h3>Hard</h3><hr><p>You are given a 2D integer array <code>intervals</code> where <code>intervals[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> represents all the integers from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> inclusively.</p> |
| 2 | + |
| 3 | +<p>A <strong>containing set</strong> is an array <code>nums</code> where each interval from <code>intervals</code> has <strong>at least two</strong> integers in <code>nums</code>.</p> |
| 4 | + |
| 5 | +<ul> |
| 6 | + <li>For example, if <code>intervals = [[1,3], [3,7], [8,9]]</code>, then <code>[1,2,4,7,8,9]</code> and <code>[2,3,4,8,9]</code> are <strong>containing sets</strong>.</li> |
| 7 | +</ul> |
| 8 | + |
| 9 | +<p>Return <em>the minimum possible size of a containing set</em>.</p> |
| 10 | + |
| 11 | +<p> </p> |
| 12 | +<p><strong class="example">Example 1:</strong></p> |
| 13 | + |
| 14 | +<pre> |
| 15 | +<strong>Input:</strong> intervals = [[1,3],[3,7],[8,9]] |
| 16 | +<strong>Output:</strong> 5 |
| 17 | +<strong>Explanation:</strong> let nums = [2, 3, 4, 8, 9]. |
| 18 | +It can be shown that there cannot be any containing array of size 4. |
| 19 | +</pre> |
| 20 | + |
| 21 | +<p><strong class="example">Example 2:</strong></p> |
| 22 | + |
| 23 | +<pre> |
| 24 | +<strong>Input:</strong> intervals = [[1,3],[1,4],[2,5],[3,5]] |
| 25 | +<strong>Output:</strong> 3 |
| 26 | +<strong>Explanation:</strong> let nums = [2, 3, 4]. |
| 27 | +It can be shown that there cannot be any containing array of size 2. |
| 28 | +</pre> |
| 29 | + |
| 30 | +<p><strong class="example">Example 3:</strong></p> |
| 31 | + |
| 32 | +<pre> |
| 33 | +<strong>Input:</strong> intervals = [[1,2],[2,3],[2,4],[4,5]] |
| 34 | +<strong>Output:</strong> 5 |
| 35 | +<strong>Explanation:</strong> let nums = [1, 2, 3, 4, 5]. |
| 36 | +It can be shown that there cannot be any containing array of size 4. |
| 37 | +</pre> |
| 38 | + |
| 39 | +<p> </p> |
| 40 | +<p><strong>Constraints:</strong></p> |
| 41 | + |
| 42 | +<ul> |
| 43 | + <li><code>1 <= intervals.length <= 3000</code></li> |
| 44 | + <li><code>intervals[i].length == 2</code></li> |
| 45 | + <li><code>0 <= start<sub>i</sub> < end<sub>i</sub> <= 10<sup>8</sup></code></li> |
| 46 | +</ul> |
0 commit comments