Amazon Coding Question – Solved

8 Live
Prime Jumps There is a game that is played as follows: There is a pawn located at cell 0, and its score is 0. There is a row of n cells numbered from 0 to n-1 from left to right. Each cell has a value, and the first cell always has a value of 0. In a single move, the pawn can move either: one cell to the right, or some number p cells to the right where p is a prime number ending in 3, e.g., 3 and 13. The pawn cannot move beyond the last cell. When the pawn enters a cell, its value is added to the score. The game ends after the pawn lands on the last cell at n-1. Determine the maximum possible score. Example cell = [0, -10, -20, -30, 50] There are n = 5 cells in the array, with cells numbered from 0 to 4.

Asked in: Amazon

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |