Implement sliding-window timestamped average | Bloomberg Interview Question