Split k trades across two assets
Asked at Two Sigma
You are given two price paths, prices_a and prices_b, and a total budget of k round trips to split between them however you like (no overlapping positions on either asset).
prices_a = [1, 5, 2, 8], prices_b = [3, 9, 1, 4], k = 2
-> 13 # one trade on A (buy 1 sell 8 = 7) + one on B (buy 3 sell 9 = 6)
Return the maximum combined profit.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.