mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
15 lines
407 B
HTML
15 lines
407 B
HTML
|
<p>设计一个算法,找出数组中最小的k个数。以任意顺序返回这k个数均可。</p>
|
|||
|
|
|||
|
<p><strong>示例:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong> arr = [1,3,5,7,2,4,6,8], k = 4
|
|||
|
<strong>输出:</strong> [1,2,3,4]
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>提示:</strong></p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li><code>0 <= len(arr) <= 100000</code></li>
|
|||
|
<li><code>0 <= k <= min(100000, len(arr))</code></li>
|
|||
|
</ul>
|