mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 03:11:42 +08:00
update
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<p>给你一个下标从 <b>0</b> 开始的整数数组 <code>nums</code> 和一个整数 <code>k</code> 。</p>
|
||||
|
||||
<p>一次操作中,你可以删除 <code>nums</code> 中的最小元素。</p>
|
||||
|
||||
<p>你需要使数组中的所有元素都大于或等于 <code>k</code> ,请你返回需要的 <strong>最少</strong> 操作次数。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong class="example">示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<b>输入:</b>nums = [2,11,10,1,3], k = 10
|
||||
<b>输出:</b>3
|
||||
<b>解释:</b>第一次操作后,nums 变为 [2, 11, 10, 3] 。
|
||||
第二次操作后,nums 变为 [11, 10, 3] 。
|
||||
第三次操作后,nums 变为 [11, 10] 。
|
||||
此时,数组中的所有元素都大于等于 10 ,所以我们停止操作。
|
||||
使数组中所有元素都大于等于 10 需要的最少操作次数为 3 。
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<b>输入:</b>nums = [1,1,2,4,9], k = 1
|
||||
<b>输出:</b>0
|
||||
<b>解释:</b>数组中的所有元素都大于等于 1 ,所以不需要对 nums 做任何操作。</pre>
|
||||
|
||||
<p><strong class="example">示例 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<b>输入:</b>nums = [1,1,2,4,9], k = 9
|
||||
<b>输出:</b>4
|
||||
<b>解释:</b>nums 中只有一个元素大于等于 9 ,所以需要执行 4 次操作。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= nums.length <= 50</code></li>
|
||||
<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li>
|
||||
<li><code>1 <= k <= 10<sup>9</sup></code></li>
|
||||
<li>输入保证至少有一个满足 <code>nums[i] >= k</code> 的下标 <code>i</code> 存在。</li>
|
||||
</ul>
|
Reference in New Issue
Block a user