Quant Memo
Coding/●●●●●

Find the balance point of a PnL series

Given a PnL series, find an index where the sum of everything strictly to its left equals the sum of everything strictly to its right. The element at the index itself belongs to neither side. Return the leftmost such index, or -1 if none exists.

pnl = [1, 7, 3, 6, 5, 6]
-> 3            # left [1,7,3]=11 equals right [5,6]=11

Return the leftmost balance index, else -1. Aim for O(n)O(n).

Your answer

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

More Coding questions