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:
@@ -0,0 +1,53 @@
|
||||
<p>给定一个整数数组 <code>arr</code> ,返回 <code>arr</code> 的 <em>最大湍流子数组的<strong>长度</strong></em><strong> </strong>。</p>
|
||||
|
||||
<p>如果比较符号在子数组中的每个相邻元素对之间翻转,则该子数组是 <strong>湍流子数组</strong> 。</p>
|
||||
|
||||
<p>更正式地来说,当 <code>arr</code> 的子数组 <code>A[i], A[i+1], ..., A[j]</code> 满足仅满足下列条件时,我们称其为<em>湍流子数组</em>:</p>
|
||||
|
||||
<ul>
|
||||
<li>若 <code>i <= k < j</code> :
|
||||
|
||||
<ul>
|
||||
<li>当 <code>k</code> 为奇数时, <code>A[k] > A[k+1]</code>,且</li>
|
||||
<li>当 <code>k</code> 为偶数时,<code>A[k] < A[k+1]</code>;</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>或 </strong>若 <code>i <= k < j</code> :
|
||||
<ul>
|
||||
<li>当 <code>k</code> 为偶数时,<code>A[k] > A[k+1]</code> ,且</li>
|
||||
<li>当 <code>k</code> 为奇数时, <code>A[k] < A[k+1]</code>。</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>arr = [9,4,2,10,7,8,8,1,9]
|
||||
<strong>输出:</strong>5
|
||||
<strong>解释:</strong>arr[1] > arr[2] < arr[3] > arr[4] < arr[5]</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>arr = [4,8,12,16]
|
||||
<strong>输出:</strong>2
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>arr = [100]
|
||||
<strong>输出:</strong>1
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= arr.length <= 4 * 10<sup>4</sup></code></li>
|
||||
<li><code>0 <= arr[i] <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user