Skip to content

Commit b699b75

Browse files
committed
502
1 parent d9cbcea commit b699b75

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Jun-15-24.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def findMaximizedCapital(self, k: int, w: int, profits: List[int], capital: List[int]) -> int:
3+
l = [[y,x] for x,y in zip(profits,capital)]
4+
l.sort()
5+
maxHeap = []
6+
heapq.heapify(maxHeap)
7+
i = 0
8+
for j in range(k):
9+
while i<len(l) and w>=l[i][0]:
10+
heapq.heappush(maxHeap,-l[i][1])
11+
i += 1
12+
if not maxHeap:
13+
break
14+
w -= heapq.heappop(maxHeap)
15+
return w

0 commit comments

Comments
 (0)