mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
24 lines
658 B
HTML
24 lines
658 B
HTML
|
<p>输入整数数组 <code>arr</code> ,找出其中最小的 <code>k</code> 个数。例如,输入4、5、1、6、2、7、3、8这8个数字,则最小的4个数字是1、2、3、4。</p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>arr = [3,2,1], k = 2
|
|||
|
<strong>输出:</strong>[1,2] 或者 [2,1]
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>arr = [0,1,2,1], k = 1
|
|||
|
<strong>输出:</strong>[0]</pre>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>限制:</strong></p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li><code>0 <= k <= arr.length <= 10000</code></li>
|
|||
|
<li><code>0 <= arr[i] <= 10000</code></li>
|
|||
|
</ul>
|