Amazon Prime Games is designing a game. The player needs to pass n rounds sequentially in this game. Rules of play are as follows:
power[i] health to complete round i.min(armor, power[i]).Determine the minimum starting health for a player to win the game.
Complete the function getMinimumValue in the editor below.
getMinimumValue has the following parameters:
int power[n]: the health cost of each roundint armor: the maximum amount of health that may be returned one round only
Returns
int: the minimum amount of health required at the beginning of the game
power = [1, 2, 6, 7] armor = 5 return = 12

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 1: 12
- Round 2: 11
- Round 3: 9
- Round 4: 8
- Final: 1
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.
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Find Minimum CostOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Select Least Resource TasksOA · Seen Jun 2026
- Product Category Group SizesPHONE SCREEN · Seen May 2026
- Count Connected ComponentsPHONE SCREEN · Seen May 2026
public int getMinimumValue(int[] power, int armor) {
// write your code here
}