You are given an integer array nums and an integer x.
You start at index
When moving from index i to index j (where i < j), you add nums[j] to your total score. However, if nums[i] and nums[j] have different parities (one is odd and the other is even), you must subtract x from your score as a penalty.
Initially, your score is equal to nums[0].
Return the maximum score you can achieve by choosing an optimal sequence of visited indices.
Constraints:
nums.length
nums[i], x
You are given an integer array nums and an integer x.
You start at index
When moving from index i to index j (where i < j), you add nums[j] to your total score. However, if nums[i] and nums[j] have different parities (one is odd and the other is even), you must subtract x from your score as a penalty.
Initially, your score is equal to nums[0].
Return the maximum score you can achieve by choosing an optimal sequence of visited indices.
Constraints:
nums.length
nums[i], x