Minimum Starting Health to Win the Game
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! π
1Example 1
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.
2Example 2
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.
Constraints
Limits and guarantees your solution can rely on.