Quant Memo
Coding/●●●●●

Count day-ranges whose PnL is divisible by m

You have a desk's daily PnL for the year. Count how many contiguous day-ranges have a total that is an exact multiple of m (including zero totals).

pnl = [4, 5, 0, -2, 7], m = 5
-> 6

Count all such ranges in 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