1330. Reverse Subarray To Maximize Array Value
https://leetcode.com/problems/reverse-subarray-to-maximize-array-value
Description
You are given an integer array nums
. The value of this array is defined as the sum of |nums[i]-nums[i+1]|
for all 0 <= i < nums.length-1
.
You are allowed to select any subarray of the given array and reverse it. You can perform this operation only once.
Find maximum possible value of the final array.
Example 1:
Example 2:
Constraints:
1 <= nums.length <= 3*10^4
-10^5 <= nums[i] <= 10^5
ac
Last updated