mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
51 lines
1.5 KiB
HTML
51 lines
1.5 KiB
HTML
<p>给定一个由不同正整数的组成的非空数组 <code>nums</code> ,考虑下面的图:</p>
|
||
|
||
<ul>
|
||
<li>有 <code>nums.length</code> 个节点,按从 <code>nums[0]</code> 到 <code>nums[nums.length - 1]</code> 标记;</li>
|
||
<li>只有当 <code>nums[i]</code> 和 <code>nums[j]</code> 共用一个大于 1 的公因数时,<code>nums[i]</code> 和 <code>nums[j]</code>之间才有一条边。</li>
|
||
</ul>
|
||
|
||
<p>返回 <em>图中最大连通组件的大小</em> 。</p>
|
||
|
||
<p> </p>
|
||
|
||
<ol>
|
||
</ol>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<p><img src="https://assets.leetcode.com/uploads/2018/12/01/ex1.png" style="height: 97px; width: 500px;" /></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [4,6,15,35]
|
||
<strong>输出:</strong>4
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<p><img src="https://assets.leetcode.com/uploads/2018/12/01/ex2.png" style="height: 85px; width: 500px;" /></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [20,50,9,63]
|
||
<strong>输出:</strong>2
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<p><img src="https://assets.leetcode.com/uploads/2018/12/01/ex3.png" style="height: 260px; width: 500px;" /></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [2,3,6,7,4,12,21,39]
|
||
<strong>输出:</strong>8
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= nums.length <= 2 * 10<sup>4</sup></code></li>
|
||
<li><code>1 <= nums[i] <= 10<sup>5</sup></code></li>
|
||
<li><code>nums</code> 中所有值都 <strong>不同</strong></li>
|
||
</ul>
|