mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Given an array <code>nums</code> with <code>n</code> integers, your task is to check if it could become non-decreasing by modifying <strong>at most one element</strong>.</p>
 | 
						|
 | 
						|
<p>We define an array is non-decreasing if <code>nums[i] <= nums[i + 1]</code> holds for every <code>i</code> (<strong>0-based</strong>) such that (<code>0 <= i <= n - 2</code>).</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> nums = [4,2,3]
 | 
						|
<strong>Output:</strong> true
 | 
						|
<strong>Explanation:</strong> You could modify the first <code>4</code> to <code>1</code> to get a non-decreasing array.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> nums = [4,2,1]
 | 
						|
<strong>Output:</strong> false
 | 
						|
<strong>Explanation:</strong> You can't get a non-decreasing array by modify at most one element.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>n == nums.length</code></li>
 | 
						|
	<li><code>1 <= n <= 10<sup>4</sup></code></li>
 | 
						|
	<li><code>-10<sup>5</sup> <= nums[i] <= 10<sup>5</sup></code></li>
 | 
						|
</ul>
 |