Maximize capital from projects
You can complete at most k projects to maximize your capital before an IPO. You start with w capital. Each project i requires a minimum capital capital[i] to start and, once finished, gives a one-time pure profit profits[i] added to your capital. You can only work one project at a time and each project at most once. Return the maximum final capital after completing at most k projects. There are at most 100000 projects, and k, w fit in 64-bit integers.
Implement
max_capital(k: int, w: int, profits: list[int], capital: list[int]) → intExamples
in
[2,0,[1,2,3],[0,1,1]]out4What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 30 min
solution.py
InputExpectedGot
[2,0,[1,2,3],[0,1,1]]4not run yetsample