A hard Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- hard
- Seniority
- L6
Problem
Given data (list of [time, value] pairs), window (positive int), and threshold (float), scan values left-to-right. For each index >= window, compute the mean and population stdev over the previous `window` values (excluding current). Flag the current value as an anomaly if |value - mean| > threshold * stdev. Return a list of dicts with keys {timestamp, value, rolling_mean, rolling_std, z_score}, each numeric field rounded to 2 decimal places, in scan order.
Summary
Spot the outliers before they page someone.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.