Practice Visit Array Positions to Maximize Score
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Begin at index 0 with score nums[0]. You may move to any later index, gaining its nums value, but each move between values of different parity also costs x points. Stop at any time. Return the greatest total score obtainable.
Source: Visit Array Positions to Maximize Score on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [2,3,6,1,9,2], x = 5
Output
13
# Example 2
Input
nums = [2,4,6,8], x = 3
Output
20
Constraints
2 <= nums.length <= 10^5
1 <= nums[i], x <= 10^6
Related LeetCode Problems
Practice more problems similar to Visit Array Positions to Maximize Score.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.