mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
30 lines
971 B
HTML
30 lines
971 B
HTML
|
<p>给你一个整数数组 <code>nums</code> 。「数组值」定义为所有满足 <code>0 <= i < nums.length-1</code> 的 <code>|nums[i]-nums[i+1]|</code> 的和。</p>
|
|||
|
|
|||
|
<p>你可以选择给定数组的任意子数组,并将该子数组翻转。但你只能执行这个操作 <strong>一次</strong> 。</p>
|
|||
|
|
|||
|
<p>请你找到可行的最大 <strong>数组值 </strong>。</p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>nums = [2,3,1,5,4]
|
|||
|
<strong>输出:</strong>10
|
|||
|
<strong>解释:</strong>通过翻转子数组 [3,1,5] ,数组变成 [2,5,1,3,4] ,数组值为 10 。
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>nums = [2,4,9,24,2,1,10]
|
|||
|
<strong>输出:</strong>68
|
|||
|
</pre>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>提示:</strong></p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li><code>1 <= nums.length <= 3*10^4</code></li>
|
|||
|
<li><code>-10^5 <= nums[i] <= 10^5</code></li>
|
|||
|
</ul>
|