1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/设置交集大小至少为2 [set-intersection-size-at-least-two].html
2022-03-29 12:43:11 +08:00

31 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>一个整数区间&nbsp;<code>[a, b]</code>&nbsp;&nbsp;(&nbsp;<code>a &lt; b</code>&nbsp;) 代表着从&nbsp;<code>a</code>&nbsp;&nbsp;<code>b</code>&nbsp;的所有连续整数,包括&nbsp;<code>a</code>&nbsp;&nbsp;<code>b</code></p>
<p>给你一组整数区间<code>intervals</code>,请找到一个最小的集合 S使得 S 里的元素与区间<code>intervals</code>中的每一个整数区间都至少有2个元素相交。</p>
<p>输出这个最小集合S的大小。</p>
<p><strong>示例 1:</strong></p>
<pre><strong>输入:</strong> intervals = [[1, 3], [1, 4], [2, 5], [3, 5]]
<strong>输出:</strong> 3
<strong>解释:</strong>
考虑集合 S = {2, 3, 4}. S与intervals中的四个区间都有至少2个相交的元素。
且这是S最小的情况故我们输出3。
</pre>
<p><strong>示例 2:</strong></p>
<pre><strong>输入:</strong> intervals = [[1, 2], [2, 3], [2, 4], [4, 5]]
<strong>输出:</strong> 5
<strong>解释:</strong>
最小的集合S = {1, 2, 3, 4, 5}.
</pre>
<p><strong>注意:</strong></p>
<ol>
<li><code>intervals</code>&nbsp;的长度范围为<code>[1, 3000]</code></li>
<li><code>intervals[i]</code>&nbsp;长度为&nbsp;<code>2</code>,分别代表左、右边界。</li>
<li><code>intervals[i][j]</code> 的值是&nbsp;<code>[0, 10^8]</code>范围内的整数。</li>
</ol>