Calculate 7-Day Rolling Average for Energy Consumption
AmazonData Scientist · OnsiteLast updated
This question evaluates programming fluency in numerical data processing and algorithmic implementation for computing moving averages and handling edge cases in time-series sequences, and it applies to Data Scientist roles while falling under the Coding & Algorithms category.
Scenario
Hiring manager wants a quick coding exercise to verify programming fluency.
Question
Write a Python function that takes a list of daily energy consumption values and returns a list containing the 7-day rolling average; handle cases with fewer than 7 observations.
Hints
Use sliding window or collections.deque; O(n) time.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.