Maximum Score with Prime Jumps
Reported by candidates from Microsoft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The edge case that kills most first attempts at this Microsoft OA, reported July 2026, is assuming you should always take the biggest jump. You shouldn't. The problem gives you a row of cells, moves of 1 or a prime ending in 3 (3, 13, 23, 43, 53...), and asks for the max score landing on cell n-1. Negative values are the trap. It's a DP over positions with a math filter on allowed jump sizes. If you've seen a jump game, you know the skeleton. The prime detail is what makes it feel new. If you blank mid-assessment, StealthCoder runs invisibly as a backup.
The problem
You are given an integer array cell representing a row of cells numbered from 0 to cell.length - 1. The value of cell[0] is always 0. A player starts at cell 0 with a score of 0. On each move, the player may: Move one cell to the right. Move p cells to the right, where p is a prime number whose decimal representation ends in 3. The player may not move beyond the final cell. Whenever the player lands on a cell, that cell's value is added to the score. The game ends when the player reaches cell cell.length - 1. Return the maximum possible score. Function maximumScore(cell: int[]) → long Examples Example 1 cell = [0,-10,-20,-30,50] return = 40 There are three ways to reach cell 4: Jump 3 cells and then move 1 cell, scoring -30 + 50 = 20. Move 1 cell and then jump 3 cells, scoring -10 + 50 = 40. Move 1 cell four times, scoring -10 - 20 - 30 + 50 = -10. The maximum possible score is 40.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is a 1D DP. Let dp[i] be the best score ending at cell i, with dp[0] = 0. Then dp[i] = cell[i] + max(dp[i-1], dp[i-p]) for every allowed prime p with p <= i. Precompute primes up to n-1 with a sieve, then keep only those where p % 10 == 3. Note that 3 is the smallest, and 2 or 5 or 7 don't count. The common pitfalls: using int instead of long for the score, forgetting that cell values can be negative so greedy long jumps fail, and testing primality per step, which blows up to O(n * sqrt(n)) per cell. Sieve once. Total cost is roughly O(n * k), where k is the count of qualifying primes below n. That's fine for moderate n but think about it if n is huge. If the live OA freezes your brain on the recurrence, StealthCoder is the hedge that hands you the structure while you type.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Maximum Score with Prime Jumps 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Microsoft's OA.
Microsoft reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Score with Prime Jumps FAQ
What's the core trick in Maximum Score with Prime Jumps?+
It's a 1D dynamic programming problem. dp[i] is the best score ending at cell i. You transition from i-1 or from i-p for every prime p ending in 3. Sieve the primes once, filter by last digit 3, and loop. Greedy fails because cell values can be negative.
Which jump sizes are actually allowed?+
Move 1, or move p where p is prime and its decimal form ends in 3. That gives 3, 13, 23, 43, 53, 73, 83 and so on. Note 33 and 63 aren't prime. Sieve first, then check p % 10 == 3. Don't hardcode a short list.
Why does a naive solution fail on this Microsoft OA?+
Two reasons. Greedy jumping fails because negative cells punish big jumps, as the example shows with 40 versus 20. And checking primality inside the DP loop is slow. Also use a 64-bit type for the score, since the function returns long.
What's the time complexity I should aim for?+
Sieve is O(n log log n). The DP is O(n * k), where k is the number of primes below n ending in 3, roughly a quarter of all primes. That's acceptable for typical constraints. If n were huge, you'd need to question the approach, but start here.
How do I prepare for this in 48 hours?+
Write a sieve from memory, then write a jump-game DP with a custom list of allowed step sizes. Test on the sample: [0,-10,-20,-30,50] should return 40. Check n=1 and all-negative arrays. That covers the whole problem shape.