Note - Similar to LC 2214
In Amazon Prime Games, a player needs to pass n rounds sequentially. The rules are as follows:
power[i] health to complete round i.min(armor, power[i]) for that round.You need to determine the minimum starting health required for the player to win the game.
Thank you so much, Spike! 😊
power = [1, 2, 6, 7] armor = 5 return = 12
Starting health = 12
Round 1: Health = 12 - 1 = 11
Round 2: Health = 11 - 2 = 9
Round 3: Health = 9 - (6 - 5) = 8
Round 4: Health = 8 - 7 = 1
The minimum starting health required to win the game is 12.
power = [1, 2, 3] armor = 1 return = 6
Starting health = 6
Round 1: Health = 6 - 1 + 1 (armor) = 6
Round 2: Health = 6 - 2 = 4
Round 3: Health = 4 - 3 = 1
The minimum starting health required to win the game is 6.
- 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 minimumStartingHealth(int[] power, int armor) {
// write your code here
}