mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 11:21:42 +08:00
add leetcode problem-cn part3
This commit is contained in:
32
算法题(国内版)/problem (Chinese)/非递减数列 [non-decreasing-array].html
Normal file
32
算法题(国内版)/problem (Chinese)/非递减数列 [non-decreasing-array].html
Normal file
@@ -0,0 +1,32 @@
|
||||
<p>给你一个长度为 <code>n</code> 的整数数组<meta charset="UTF-8" /> <code>nums</code> ,请你判断在 <strong>最多 </strong>改变 <code>1</code> 个元素的情况下,该数组能否变成一个非递减数列。</p>
|
||||
|
||||
<p>我们是这样定义一个非递减数列的: 对于数组中任意的 <code>i</code> <code>(0 <= i <= n-2)</code>,总满足 <code>nums[i] <= nums[i + 1]</code>。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong> nums = [4,2,3]
|
||||
<strong>输出:</strong> true
|
||||
<strong>解释:</strong> 你可以通过把第一个 4 变成 1 来使得它成为一个非递减数列。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong> nums = [4,2,1]
|
||||
<strong>输出:</strong> false
|
||||
<strong>解释:</strong> 你不能在只改变一个元素的情况下将其变为非递减数列。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
<meta charset="UTF-8" />
|
||||
|
||||
<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>
|
Reference in New Issue
Block a user