Code RoomMaximize capital from projects
HardPrep Room Coding #1500

Maximize capital from projects

CodingAlgorithms & data structuresSenior–Staff~30 min

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]) → int
Examples
in[2,0,[1,2,3],[0,1,1]]out4
What 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
InputExpectedGot
[2,0,[1,2,3],[0,1,1]]4not run yetsample