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)/不同整数的最少数目 [least-number-of-unique-integers-after-k-removals].html
2022-03-29 12:43:11 +08:00

30 lines
951 B
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>给你一个整数数组 <code>arr</code> 和一个整数 <code>k</code> 。现需要从数组中恰好移除 <code>k</code> 个元素,请找出移除后数组中不同整数的最少数目。</p>
<ol>
</ol>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>arr = [5,5,4], k = 1
<strong>输出:</strong>1
<strong>解释:</strong>移除 1 个 4 ,数组中只剩下 5 一种整数。
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>arr = [4,3,1,1,3,3,2], k = 3
<strong>输出:</strong>2
<strong>解释:</strong>先移除 4、2 ,然后再移除两个 1 中的任意 1 个或者三个 3 中的任意 1 个,最后剩下 1 和 3 两种整数。</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= arr.length&nbsp;&lt;= 10^5</code></li>
<li><code>1 &lt;= arr[i] &lt;= 10^9</code></li>
<li><code>0 &lt;= k&nbsp;&lt;= arr.length</code></li>
</ul>