Allocate a fixed budget across strategies
Asked at Two Sigma, DE Shaw
You can fund each strategy at most once. Strategy i needs costs[i] of capital and is expected to earn profits[i]. With a total budget, choose a subset that maximizes expected profit without overspending.
costs = [2, 3, 4]
profits = [3, 4, 5]
budget = 5
-> 7 # fund strategies 0 and 1: cost 2+3=5, profit 3+4=7
Return the maximum total profit fitting within the budget (0/1 knapsack). Each strategy is all-or-nothing.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.