Skip to content

Commit 518f8d3

Browse files
authored
Create minimum-health-to-beat-game.py
1 parent e52fd84 commit 518f8d3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Python/minimum-health-to-beat-game.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
# greedy
5+
class Solution(object):
6+
def minimumHealth(self, damage, armor):
7+
"""
8+
:type damage: List[int]
9+
:type armor: int
10+
:rtype: int
11+
"""
12+
return sum(damage)-min(max(damage), armor)+1

0 commit comments

Comments
 (0)