Given an array of integers nums, in each move, you can select any element and reduce its value by
An array nums is a zigzag array if either of the following conditions is satisfied:
Every even indexed element is strictly greater than its adjacent elements (that is, for every even index nums[i] > nums[i - 1] and nums[i] > nums[i + 1], whenever the adjacent elements exist).
Every odd indexed element is strictly greater than its adjacent elements (that is, for every odd index nums[i] > nums[i - 1] and nums[i] > nums[i + 1], whenever the adjacent elements exist).
Return the minimum number of moves needed to transform nums into a zigzag array.
Constraints:
nums.length
nums[i]
Given an array of integers nums, in each move, you can select any element and reduce its value by
An array nums is a zigzag array if either of the following conditions is satisfied:
Every even indexed element is strictly greater than its adjacent elements (that is, for every even index nums[i] > nums[i - 1] and nums[i] > nums[i + 1], whenever the adjacent elements exist).
Every odd indexed element is strictly greater than its adjacent elements (that is, for every odd index nums[i] > nums[i - 1] and nums[i] > nums[i + 1], whenever the adjacent elements exist).
Return the minimum number of moves needed to transform nums into a zigzag array.
Constraints:
nums.length
nums[i]