[
greedy
array
]
Leetcode 2214. Minimum Health to Beat Game
Problem statement
https://leetcode.com/problems/minimum-health-to-beat-game
Solution
Just take the biggest damage we can deal.
Complexity
It is O(n)
for time and space.
Code
class Solution:
def minimumHealth(self, D, A):
return sum(D) + 1 - max([min(x, A) for x in D])