1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 03:11:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2024-01-30 22:20:37 +08:00
parent 9e50b3cd07
commit a697596e35
23 changed files with 15743 additions and 13660 deletions

View File

@@ -0,0 +1,36 @@
<p>给你一个<strong> 正整数 </strong>数组 <code>nums</code></p>
<p>你需要从数组中选出一个满足下述条件的<span data-keyword="subset">子集</span></p>
<ul>
<li>你可以将选中的元素放置在一个下标从 <strong>0</strong> 开始的数组中,并使其遵循以下模式:<code>[x, x<sup>2</sup>, x<sup>4</sup>, ..., x<sup>k/2</sup>, x<sup>k</sup>, x<sup>k/2</sup>, ..., x<sup>4</sup>, x<sup>2</sup>, x]</code><strong>注意</strong><code>k</code> 可以是任何 <strong>非负</strong> 的 2 的幂)。例如,<code>[2, 4, 16, 4, 2]</code><code>[3, 9, 3]</code> 都符合这一模式,而 <code>[2, 4, 8, 4, 2]</code> 则不符合。</li>
</ul>
<p>返回满足这些条件的子集中,元素数量的 <strong>最大值 </strong><em></em></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [5,4,1,2,2]
<strong>输出:</strong>3
<strong>解释:</strong>选择子集 {4,2,2} ,将其放在数组 [2,4,2] 中,它遵循该模式,且 2<sup>2</sup> == 4 。因此答案是 3 。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1,3,2,4]
<strong>输出:</strong>1
<strong>解释:</strong>选择子集 {1},将其放在数组 [1] 中,它遵循该模式。因此答案是 1 。注意我们也可以选择子集 {2} 、{4} 或 {3} ,可能存在多个子集都能得到相同的答案。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>