Citi Interview Question

Propose an efficient code that count moving average.