Compute moving and weighted averages from a stream | Atlassian Interview Question