1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-12-15 23:22:36 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/统计合格元素的数目 [count-elements-with-at-least-k-greater-values].html
2025-12-06 16:04:11 +08:00

43 lines
1.4 KiB
HTML
Raw Permalink 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>n</code> 的整数数组 <code>nums</code> 和一个整数 <code>k</code></p>
<p>如果数组 <code>nums</code> 中的某个元素满足以下条件,则称其为 <strong>合格元素</strong>:存在&nbsp;<strong>至少</strong> <code>k</code> 个元素&nbsp;<strong>严格大于&nbsp;</strong>它。</p>
<p>返回一个整数,表示数组 <code>nums</code> 中合格元素的总数。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [3,1,2], k = 1</span></p>
<p><strong>输出:</strong> <span class="example-io">2</span></p>
<p><strong>解释:</strong></p>
<p>元素 1 和 2 均有至少 <code>k = 1</code> 个元素大于它们。<br />
没有元素比 3 更大。因此答案是 2。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [5,5,5], k = 2</span></p>
<p><strong>输出:</strong> <span class="example-io">0</span></p>
<p><strong>解释:</strong></p>
<p>由于所有元素都等于 5没有任何元素比其他元素大。因此答案是 0。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n == nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
<li><code>0 &lt;= k &lt; n</code></li>
</ul>