Skip to content

Commit 2510ed1

Browse files
Merge pull request #2021 from CodingTestStudy2/최민지
[최민지] Day13
2 parents 3e4a353 + 0fef7cb commit 2510ed1

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎leetcode3/최민지/1665.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def minimumEffort(self, tasks: List[List[int]]) -> int:
3+
tasks.sort(key=lambda x: x[1] - x[0], reverse=True)
4+
5+
answer = 0
6+
energy = 0
7+
8+
for actual, minimum in tasks:
9+
if energy < minimum:
10+
answer += minimum - energy
11+
energy = minimum
12+
13+
energy -= actual
14+
15+
return answer

0 commit comments

Comments
 (0)