Maximum Game Board Score
Problem statement
You are given a game board with spaces arranged in a straight line, each space worth a different number of points, either positive or negative. The goal of the game is to accumulate as many points as possible.
Your game piece can start at any point on the board, and it can jump exactly k number of spaces at a time, only moving to the right, accumulating the number of points written on each space your piece lands on. Once your piece jumps past the final space, the game ends.
Given a game board, and a jump length, choose the ideal starting space to maximize the number of points gained. Return the total points.
Function
maxGameScore(gameVal: int[], k: int) → intExamples
Example 1
gameVal = [2,-3,4,6,1]k = 2return = 7Suppose game_val = [2, -3, 4, 6, 1] and k = 2.
Output: 7
Choose index = 1 as starting point.
2 + 4 + 1 = 7
Constraints
1 ≤ size of game_val ≤ 10^6-10^3 ≤ game_val[i] ≤ 10^31 ≤ k < size of game_val