You are given an integer array nums.
Consider partitioning nums into one or more contiguous nonempty subarrays. The cost of a subarray nums[l \dots r] is calculated as:
$ ext{cost}(l, r) = ext{nums}[l] - ext{nums}[l + 1] + ext{nums}[l + 2] - \dots + ext{nums}[r] imes (-1)^{r - l}$
The total cost of the partition is the sum of the costs of each subarray.
Return the maximum possible total cost after partitioning nums.
Constraints:
nums.length
nums[i]
You are given an integer array nums.
Consider partitioning nums into one or more contiguous nonempty subarrays. The cost of a subarray nums[l \dots r] is calculated as:
$ ext{cost}(l, r) = ext{nums}[l] - ext{nums}[l + 1] + ext{nums}[l + 2] - \dots + ext{nums}[r] imes (-1)^{r - l}$
The total cost of the partition is the sum of the costs of each subarray.
Return the maximum possible total cost after partitioning nums.
Constraints:
nums.length
nums[i]