1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/统计最大元素出现至少 K 次的子数组 [count-subarrays-where-max-element-appears-at-least-k-times].html
2023-12-20 15:51:53 +08:00

34 lines
1.1 KiB
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>nums</code> 和一个 <strong>正整数</strong> <code>k</code></p>
<p>请你统计有多少满足 「&nbsp;<code>nums</code> 中的 <strong>最大</strong> 元素」至少出现 <code>k</code> 次的子数组,并返回满足这一条件的子数组的数目。</p>
<p>子数组是数组中的一个连续元素序列。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,3,2,3,3], k = 2
<strong>输出:</strong>6
<strong>解释:</strong>包含元素 3 至少 2 次的子数组为:[1,3,2,3]、[1,3,2,3,3]、[3,2,3]、[3,2,3,3]、[2,3,3] 和 [3,3] 。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1,4,2,1], k = 3
<strong>输出:</strong>0
<strong>解释:</strong>没有子数组包含元素 4 至少 3 次。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
<li><code>1 &lt;= k &lt;= 10<sup>5</sup></code></li>
</ul>