You are given an integer array nums of length n.
The pulse value of nums is defined as:
pulse(arr) = arr[0] - arr[1] + arr[2] - arr[3] + ...
You may perform at most one operation: choose two indices l and r such that 0 <= l < r < n, then left-rotate the subarray nums[l..r] by exactly one position. A left rotation moves the first element of the subarray to its end. For example, [a, b, c, d] becomes [b, c, d, a].
Return the maximum pulse value of nums that can be obtained after performing at most one such operation.
Constraints:
1 ≤ n == nums.length ≤ 10⁵
−10⁹ ≤ nums[i] ≤ 10⁹
You are given an integer array nums of length n.
The pulse value of nums is defined as:
pulse(arr) = arr[0] - arr[1] + arr[2] - arr[3] + ...
You may perform at most one operation: choose two indices l and r such that 0 <= l < r < n, then left-rotate the subarray nums[l..r] by exactly one position. A left rotation moves the first element of the subarray to its end. For example, [a, b, c, d] becomes [b, c, d, a].
Return the maximum pulse value of nums that can be obtained after performing at most one such operation.
Constraints:
1 ≤ n == nums.length ≤ 10⁵
−10⁹ ≤ nums[i] ≤ 10⁹