The Narrow Lens
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L5
Problem
You are smoothing a stream of raw sensor readings before it feeds an alerting pipeline, replacing each reading with a trailing average that damps momentary spikes. Given the readings `values` and a `window_size`, return a list of the same length where each element is the average of the readings up to and including that position, looking back at most `window_size` readings. Near the start, before `window_size` readings exist, average only the ones seen so far.
Summary
A narrow timeframe. Everything inside matters.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.