Amazon Coding Question – Solved

12 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

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |