The Anomaly Detector
A hard Python mock interview question on DataDriven. Practice with AI-powered feedback, real code execution, and a hire/no-hire decision.
- Domain
- Python
- Difficulty
- hard
- Seniority
- L6
Interview Prompt
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.
How This Interview Works
- Read the vague prompt (just like a real interview)
- Ask clarifying questions to the AI interviewer
- Write your python solution with real code execution
- Get instant feedback and a hire/no-hire decision