Project profit maximization
You can launch any subset of projects. Project i yields profit projects[i] (a non-negative integer). Each entry [p, m] in requires means project p can only run if machine m is purchased; machine m costs machines[m] (non-negative). A machine, once bought, may be shared by any number of projects. Choose the subset of projects that maximizes total profit minus total machine cost. Return that maximum net value (it is never negative since launching nothing yields 0). Constraints: up to 60 projects, up to 60 machines.
Implement
max_project_profit(projects: list[int], machines: list[int], requires: list[list[int]]) → intExamples
in
[[10,10],[5],[[0,0],[1,0]]]out15What 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 40 min
solution.py
InputExpectedGot
[[10,10],[5],[[0,0],[1,0]]]15not run yetsample