Amazon Coding Question – Solved

4 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

| Amazon has multiple delivery centers for the distribution of its goods. In one … |
| A user is using the Amazon fitness tracker and is engaged in a jumping exercise… |
| Amazon Kindle has several e-books that customers can purchase directly. There a… |
| The engineering team at an Amazon fulfillment center is optimizing n high-perfo… |
| The supply chain manager at one of Amazon's warehouses is shipping the last con… |
| Determine the highest value after executing n steps on an infinite 2D grid that… |