Compute moving average over last N stream | Atlassian Interview Question