mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			58 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个长度为 <code>n</code> 的数组 <code>nums</code> 和一个整数 <code>m</code> 。请你判断能否执行一系列操作,将数组拆分成 <code>n</code> 个 <strong>非空 </strong>数组。</p>
 | 
						||
 | 
						||
<p>在每一步操作中,你可以选择一个 <strong>长度至少为 2</strong> 的现有数组(之前步骤的结果) 并将其拆分成 <strong>2</strong> 个子数组,而得到的 <strong>每个</strong> 子数组,<strong>至少</strong> 需要满足以下条件之一:</p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li>子数组的长度为 1 ,或者</li>
 | 
						||
	<li>子数组元素之和 <strong>大于或等于</strong>  <code>m</code> 。</li>
 | 
						||
</ul>
 | 
						||
 | 
						||
<p>如果你可以将给定数组拆分成 <code>n</code> 个满足要求的数组,返回 <code>true</code><em> </em>;否则,返回 <code>false</code> 。</p>
 | 
						||
 | 
						||
<p><strong>注意:</strong>子数组是数组中的一个连续非空元素序列。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [2, 2, 1], m = 4
 | 
						||
<strong>输出:</strong>true
 | 
						||
<strong>解释:</strong>
 | 
						||
第 1 步,将数组 nums 拆分成 [2, 2] 和 [1] 。
 | 
						||
第 2 步,将数组 [2, 2] 拆分成 [2] 和 [2] 。
 | 
						||
因此,答案为 true 。</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [2, 1, 3], m = 5 
 | 
						||
<strong>输出:</strong>false
 | 
						||
<strong>解释:
 | 
						||
</strong>存在两种不同的拆分方法:
 | 
						||
第 1 种,将数组 nums 拆分成 [2, 1] 和 [3] 。
 | 
						||
第 2 种,将数组 nums 拆分成 [2] 和 [1, 3] 。
 | 
						||
然而,这两种方法都不满足题意。因此,答案为 false 。</pre>
 | 
						||
 | 
						||
<p><strong>示例 3:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [2, 3, 3, 2, 3], m = 6
 | 
						||
<strong>输出:</strong>true
 | 
						||
<strong>解释:</strong>
 | 
						||
第 1 步,将数组 nums 拆分成 [2, 3, 3, 2] 和 [3] 。
 | 
						||
第 2 步,将数组 [2, 3, 3, 2] 拆分成 [2, 3, 3] 和 [2] 。
 | 
						||
第 3 步,将数组 [2, 3, 3] 拆分成 [2] 和 [3, 3] 。
 | 
						||
第 4 步,将数组 [3, 3] 拆分成 [3] 和 [3] 。
 | 
						||
因此,答案为 true 。 </pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= n == nums.length <= 100</code></li>
 | 
						||
	<li><code>1 <= nums[i] <= 100</code></li>
 | 
						||
	<li><code>1 <= m <= 200</code></li>
 | 
						||
</ul>
 |