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)/数组大小减半 [reduce-array-size-to-the-half].html
2022-03-29 12:43:11 +08:00

34 lines
1.1 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>arr</code>。你可以从中选出一个整数集合,并删除这些整数在数组中的每次出现。</p>
<p>返回&nbsp;<strong>至少</strong>&nbsp;能删除数组中的一半整数的整数集合的最小大小。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>arr = [3,3,3,3,5,5,5,2,2,7]
<strong>输出:</strong>2
<strong>解释:</strong>选择 {3,7} 使得结果数组为 [5,5,5,2,2]、长度为 5原数组长度的一半
大小为 2 的可行集合有 {3,5},{3,2},{5,2}。
选择 {2,7} 是不可行的,它的结果数组为 [3,3,3,3,5,5,5],新数组长度大于原数组的二分之一。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>arr = [7,7,7,7,7,7]
<strong>输出:</strong>1
<strong>解释:</strong>我们只能选择集合 {7},结果数组为空。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= arr.length &lt;= 10<sup>5</sup></code></li>
<li><code>arr.length</code>&nbsp;为偶数</li>
<li><code>1 &lt;= arr[i] &lt;= 10<sup>5</sup></code></li>
</ul>