Three positions that net to flat
Asked at Optiver, SIG
Given signed position sizes (longs positive, shorts negative), find all unique triples that net to exactly zero, three positions that together leave you flat. Triples that are reorderings of each other count once.
positions = [-2, -1, 0, 1, 2]
-> [[-2, 0, 2], [-1, 0, 1]]
Return all unique zero-sum triples. Aim for .
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.