Code Room
CodingHardcod-g881
Subject Max flowLevel Senior–Staff~40 minCommon in Algorithms & data structures interviewsIndustries Software development, Technology

Question

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]]) → int
Examples
in[[10,10],[5],[[0,0],[1,0]]]out15
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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.