Maximum Game Board Score
Reported by candidates from JP Morgan's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The JP Morgan OA reported in September 2026 has a problem called Maximum Game Board Score, and the mistake that sinks a first attempt is stopping a jump chain early because the running total turned negative. The rules say the piece keeps jumping k spaces until it leaves the board, so you can't bail out. Pick any start, add every k-th value to the right, and return the best total. Arrays go up to 10^6 elements, so a naive loop from every start will time out. It's a simple backward DP in disguise. If you blank when the clock is running, StealthCoder is the invisible safety net on your screen during the live OA.
The problem
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) → int Examples Example 1 gameVal = [2,-3,4,6,1] k = 2 return = 7 Suppose 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^3 1 ≤ k < size of game_val
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to compute chain sums from the right. Define dp[i] = gameVal[i] + dp[i+k], with dp[i+k] treated as 0 when i+k is past the end. Loop i from n-1 down to 0, fill dp in one pass, and track the max across all i. That's O(n) time and O(n) space, or you can reuse the input array if you're allowed to mutate it. The common pitfall is adding max(0, dp[i+k]), which lets the piece quit early. The rules forbid that, so a start with a negative tail must pay for it. Another trap is brute force from every start, which is O(n^2/k) and dies at 10^6 with small k. Initialize the best answer to negative infinity, because every value can be negative. If the recurrence slips away mid-assessment, StealthCoder can hand you the clean version in real time.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Maximum Game Board Score cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass JP Morgan's OA.
JP Morgan reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Game Board Score FAQ
What's the trick in Maximum Game Board Score?+
Work right to left. Each cell's best chain total is its own value plus the total of the cell k steps ahead, or zero if that's off the board. One pass fills everything, and the answer is the max over all cells. No nested loops needed.
Can I stop jumping when the score goes negative?+
No. The statement says the game only ends once the piece jumps past the final space. So the tail of a chain is forced. Don't clamp dp[i+k] to zero. A start whose forced tail is negative simply scores lower, and you compare it against other starts.
Why does brute force fail here?+
The board can hold up to 10^6 spaces. Simulating a chain from every start costs about n/k jumps each, so total work is roughly n^2/k. With k=1 that's around 10^12 operations. The right-to-left DP does n operations in total.
Should I initialize the answer to 0?+
No. Values range from -1000 to 1000, and every start has at least one landing, so the true answer can be negative. Start the best at negative infinity or at dp[n-1]. Initializing to 0 returns a wrong answer on all-negative boards.
How do I prepare for this in 48 hours?+
Write the dp[i] = val[i] + dp[i+k] solution once from memory, then test it on the sample [2,-3,4,6,1] with k=2, which gives 7. Also try an all-negative array and k=1. Note the sample explanation says index 1, but the sum 2+4+1 starts at 0-based index 0.