Quant Memo
Coding/●●●●●

Best cumulative gain run

Asked at Jump Trading, Five Rings

Given a series of period returns (some negative), find the largest total achievable by any contiguous run, the best winning streak, measured by summed return.

returns = [-2, 3, -1, 4, -10, 2]
-> 6            # the run [3, -1, 4]

Return the maximum contiguous sum. 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