FastPrepMaximum Score with Prime Jumps
Problems/Maximum Score with Prime Jumps

Maximum Score with Prime Jumps

Microsoft logoMicrosoft● MediumINTERNFULLTIMEOA
QuestionFunctionExamples

Problem statement

Special thanks: 🌷 A special thank you to our lovely, amazing frenz who shared that this question appeared again on October 21, 2026 and October 24, 2026! (∩˃o˂∩)♡ 🩷

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.

More Microsoft problems

  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public long maximumScore(int[] cell) {
        // Write your code here
    }

}
Checking account…