Amazon Coding Question – Solved

6 Live
Amazon Prime Games is designing a game. The player needs to pass n rounds sequentially in this game. Rules of play are as follows: - The player loses power[i] health to complete round - The player's health must be greater than 0 at all times. - The player can choose to use armor in any one round. The armor will prevent damage of min(armor, power[il). Determine the minimum starting health for a player to win the game. Example power = [1, 2, 6, 7] armor = 5 Give the player 12 units of health at the beginning of the game. One of the optimal strategies is to use the armor in the third round and only lose 1 unit instead of 6. The health of the player after each round is: Round, health 0. 12 1. 12 - power[0] =12-1=11 2. 11 - power[1] = 11 -2 =9 3.9 - power[2] + armor=9-6+5=8 4. 8 - power[3] =8-7=1 No lower starting health will allow a win. Function Description Complete the function getMinimumValue in the editor below.

Asked in: Amazon

Image of the Question

Question Image 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… |