You are given an integer array nums.
You start by picking a starting position curr such that nums[curr] = 0 and choosing a direction: left or right.
The process then proceeds as follows:
If curr goes out of bounds, meaning curr curr nums.length, the process finishes.
If nums[curr] = 0, continue moving in the current direction by one index (decrement curr if moving left, or increment curr if moving right).
If nums[curr] > 0, decrease nums[curr] by
A choice of starting index curr and initial direction is considered valid if every element in nums becomes
Return the total number of valid selections.
Constraints:
nums.length
nums[i]
There is at least one element i where nums[i] == 0.
You are given an integer array nums.
You start by picking a starting position curr such that nums[curr] = 0 and choosing a direction: left or right.
The process then proceeds as follows:
If curr goes out of bounds, meaning curr curr nums.length, the process finishes.
If nums[curr] = 0, continue moving in the current direction by one index (decrement curr if moving left, or increment curr if moving right).
If nums[curr] > 0, decrease nums[curr] by
A choice of starting index curr and initial direction is considered valid if every element in nums becomes
Return the total number of valid selections.
Constraints:
nums.length
nums[i]
There is at least one element i where nums[i] == 0.