1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/大小为 K 且平均值大于等于阈值的子数组数目 [number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold].html
2022-03-29 12:43:11 +08:00

33 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>给你一个整数数组&nbsp;<code>arr</code>&nbsp;和两个整数 <code>k</code>&nbsp;<code>threshold</code>&nbsp;</p>
<p>请你返回长度为 <code>k</code>&nbsp;且平均值大于等于&nbsp;<code>threshold</code>&nbsp;的子数组数目。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4
<strong>输出:</strong>3
<strong>解释:</strong>子数组 [2,5,5],[5,5,5] 和 [5,5,8] 的平均值分别为 45 和 6 。其他长度为 3 的子数组的平均值都小于 4 threshold 的值)。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5
<strong>输出:</strong>6
<strong>解释:</strong>前 6 个长度为 3 的子数组平均值都大于 5 。注意平均值不是整数。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= arr.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= arr[i] &lt;= 10<sup>4</sup></code></li>
<li><code>1 &lt;= k &lt;= arr.length</code></li>
<li><code>0 &lt;= threshold &lt;= 10<sup>4</sup></code></li>
</ul>