717. Reverse Subarray To Maximize Array Value
Given an array of integers called nums, the value of this array is defined as the sum of the absolute differences between consecutive elements. You are allowed to select a subarray of nums and reverse it. However, you can only perform this operation once. Find the maximum possible value of the final array.
The first line of input contains the size of the array. The second line contains the elements of the array.
Output the maximum possible value of the final array.
5 2 3 1 5 4
1 <= nums.length <= 3 * 10^4 -10^5 <= nums[i] <= 10^5