mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> ,你必须将数组划分为一个或多个 <strong>连续</strong> 子数组。</p>
 | 
						||
 | 
						||
<p>如果获得的这些子数组中每个都能满足下述条件<strong> 之一</strong> ,则可以称其为数组的一种 <strong>有效</strong> 划分:</p>
 | 
						||
 | 
						||
<ol>
 | 
						||
	<li>子数组 <strong>恰</strong> 由 <code>2</code> 个相等元素组成,例如,子数组 <code>[2,2]</code> 。</li>
 | 
						||
	<li>子数组 <strong>恰</strong> 由 <code>3</code> 个相等元素组成,例如,子数组 <code>[4,4,4]</code> 。</li>
 | 
						||
	<li>子数组 <strong>恰</strong> 由 <code>3</code> 个连续递增元素组成,并且相邻元素之间的差值为 <code>1</code> 。例如,子数组 <code>[3,4,5]</code> ,但是子数组 <code>[1,3,5]</code> 不符合要求。</li>
 | 
						||
</ol>
 | 
						||
 | 
						||
<p>如果数组 <strong>至少</strong> 存在一种有效划分,返回 <code>true</code><em> </em>,否则,返回 <code>false</code> 。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [4,4,4,5,6]
 | 
						||
<strong>输出:</strong>true
 | 
						||
<strong>解释:</strong>数组可以划分成子数组 [4,4] 和 [4,5,6] 。
 | 
						||
这是一种有效划分,所以返回 true 。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [1,1,1,2]
 | 
						||
<strong>输出:</strong>false
 | 
						||
<strong>解释:</strong>该数组不存在有效划分。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>2 <= nums.length <= 10<sup>5</sup></code></li>
 | 
						||
	<li><code>1 <= nums[i] <= 10<sup>6</sup></code></li>
 | 
						||
</ul>
 |