Design O(1) cache and moving average | Atlassian Interview Question