1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/最长的严格递增或递减子数组 [longest-strictly-increasing-or-strictly-decreasing-subarray].html
2024-04-07 13:02:43 +08:00

63 lines
2.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数数组 <code>nums</code></p>
<p>返回数组 <code>nums</code><strong> 严格递增 </strong><strong>严格递减 </strong>的最长非空子数组的长度。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">nums = [1,4,3,3,2]</span></p>
<p><strong>输出:</strong><span class="example-io">2</span></p>
<p><strong>解释:</strong></p>
<p><code>nums</code> 中严格递增的子数组有<code>[1]</code><code>[2]</code><code>[3]</code><code>[3]</code><code>[4]</code> 以及 <code>[1,4]</code></p>
<p><code>nums</code> 中严格递减的子数组有<code>[1]</code><code>[2]</code><code>[3]</code><code>[3]</code><code>[4]</code><code>[3,2]</code> 以及 <code>[4,3]</code></p>
<p>因此,返回 <code>2</code></p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">nums = [3,3,3,3]</span></p>
<p><strong>输出:</strong><span class="example-io">1</span></p>
<p><strong>解释:</strong></p>
<p><code>nums</code> 中严格递增的子数组有 <code>[3]</code><code>[3]</code><code>[3]</code> 以及 <code>[3]</code></p>
<p><code>nums</code> 中严格递减的子数组有 <code>[3]</code><code>[3]</code><code>[3]</code> 以及 <code>[3]</code></p>
<p>因此,返回 <code>1</code></p>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">nums = [3,2,1]</span></p>
<p><strong>输出:</strong><span class="example-io">3</span></p>
<p><strong>解释:</strong></p>
<p><code>nums</code> 中严格递增的子数组有 <code>[3]</code><code>[2]</code> 以及 <code>[1]</code></p>
<p><code>nums</code> 中严格递减的子数组有 <code>[3]</code><code>[2]</code><code>[1]</code><code>[3,2]</code><code>[2,1]</code> 以及 <code>[3,2,1]</code></p>
<p>因此,返回 <code>3</code></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 50</code></li>
<li><code>1 &lt;= nums[i] &lt;= 50</code></li>
</ul>