Went with a sliding window approach, which felt right.
Start by clarifying the requirements: confirm whether the rolling average should be computed only when there are at least 7 data points, or if partial windows should be averaged. Then outline an efficient O(n) solution using a sliding window sum, and discuss edge cases like empty input, fewer than 7 points, and handling of missing values.
Pro tip: Mention that for large-scale data (e.g., Amazon-scale), you'd use a streaming approach with a deque to maintain the window and avoid storing the entire list, and note that pandas' rolling(window=7).mean() is a common production shortcut but may not handle edge cases as explicitly.
Ask whether the output should have the same length as the input (with None or NaN for the first 6 days) or only include days with a full 7-day window. Also confirm how to handle empty lists, non-numeric values, and missing data.
Decide between a simple loop with sum() for small inputs or an O(n) sliding window using a running sum (or deque) for efficiency. Discuss time and space complexity.
Write the code, explicitly handling len(data) < 7 by either returning an empty list, a list of None, or the average of available points based on clarified requirements. Include input validation.
Walk through test cases: empty list, 1-6 points, exactly 7 points, more than 7 points, and data with None or zeros. Verify the output matches expectations.
Explain how the solution would scale to millions of records (e.g., streaming, chunking) and mention libraries like pandas or NumPy that offer optimized rolling operations.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.