mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个整数数组 <code>nums</code> 和一个整数 <code>k</code> ,找出 <code>nums</code> 中和至少为 <code>k</code> 的 <strong>最短非空子数组</strong> ,并返回该子数组的长度。如果不存在这样的 <strong>子数组</strong> ,返回 <code>-1</code> 。</p>
 | 
						||
 | 
						||
<p><strong>子数组</strong> 是数组中 <strong>连续</strong> 的一部分。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<ol>
 | 
						||
</ol>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [1], k = 1
 | 
						||
<strong>输出:</strong>1
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [1,2], k = 4
 | 
						||
<strong>输出:</strong>-1
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 3:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [2,-1,2], k = 3
 | 
						||
<strong>输出:</strong>3
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
 | 
						||
	<li><code>-10<sup>5</sup> <= nums[i] <= 10<sup>5</sup></code></li>
 | 
						||
	<li><code>1 <= k <= 10<sup>9</sup></code></li>
 | 
						||
</ul>
 |