Quant Memo
Coding/●●●●

Pick non-overlapping trades for maximum profit

Asked at Citadel, Jump Trading

Each candidate trade has a start time, an end time, and a profit. Only one trade can run at a time (windows must not overlap; touching endpoints are allowed). Choose a set of compatible trades that maximizes total profit.

trades = [(1,3,50), (2,5,20), (4,6,70), (6,7,30)]   # (start, end, profit)
-> 150      # (1,3,50) + (4,6,70) + (6,7,30)

Return the maximum achievable profit (weighted interval scheduling). Greedily grabbing the biggest profit or the earliest finish can be suboptimal.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions