mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
41 lines
1.1 KiB
HTML
41 lines
1.1 KiB
HTML
<p>如果数组是单调递增或单调递减的,那么它是 <strong>单调 </strong><em>的</em>。</p>
|
||
|
||
<p>如果对于所有 <code>i <= j</code>,<code>nums[i] <= nums[j]</code>,那么数组 <code>nums</code> 是单调递增的。 如果对于所有 <code>i <= j</code>,<code>nums[i]> = nums[j]</code>,那么数组 <code>nums</code> 是单调递减的。</p>
|
||
|
||
<p>当给定的数组 <code>nums</code> 是单调数组时返回 <code>true</code>,否则返回 <code>false</code>。</p>
|
||
|
||
<p> </p>
|
||
|
||
<ol>
|
||
</ol>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [1,2,2,3]
|
||
<strong>输出:</strong>true
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [6,5,4,4]
|
||
<strong>输出:</strong>true
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [1,3,2]
|
||
<strong>输出:</strong>false
|
||
</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>
|
||
</ul>
|