Practice Reverse Subarray To Maximize Array Value
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
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.
Source: Reverse Subarray To Maximize Array Value on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [2,3,1,5,4]
10
# Example 2
nums = [2,4,9,24,2,1,10]
68
Constraints
Related LeetCode Problems
Practice more problems similar to Reverse Subarray To Maximize Array Value.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.