mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个整数数组 <code>arr</code> 和两个整数 <code>k</code> 和 <code>threshold</code> 。</p>
 | 
						||
 | 
						||
<p>请你返回长度为 <code>k</code> 且平均值大于等于 <code>threshold</code> 的子数组数目。</p>
 | 
						||
 | 
						||
<p> </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] 的平均值分别为 4,5 和 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> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= arr.length <= 10<sup>5</sup></code></li>
 | 
						||
	<li><code>1 <= arr[i] <= 10<sup>4</sup></code></li>
 | 
						||
	<li><code>1 <= k <= arr.length</code></li>
 | 
						||
	<li><code>0 <= threshold <= 10<sup>4</sup></code></li>
 | 
						||
</ul>
 |