Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Anomaly Detection for Furnace Data
00:00
5 left

Anomaly Detection for Furnace Data

HardPython

Problem

Ati's Furnace Monitoring surface receives temperature readings from a titanium melting furnace in chronological order. Implement a robust anomaly detector that identifies readings whose deviation from nearby temperatures is unusually large, without allowing isolated extreme values to distort the baseline.

For each reading at index i, examine up to radius readings immediately before and after it, excluding the reading itself. Compute the neighborhood median and its median absolute deviation, or MAD. A reading is anomalous when its absolute deviation from the neighborhood median is greater than threshold * 1.4826 * MAD. If the MAD is zero, mark the reading anomalous when it differs from the neighborhood median. Return anomalous indices in ascending order.

Formal Specification

Input is readings, a nonempty list of numbers, radius, a positive integer, and threshold, a positive number. The output is a list of integer indices. At the boundaries, use all available neighbors. The input is already ordered by time.

Constraints

  • 3 <= len(readings) <= 200000
  • 1 <= radius <= 500
  • 0 < threshold <= 20
  • -10000 <= readings[i] <= 10000
  • Readings may contain integers or floating-point values

Function Signature

def detect_temperature_anomalies(readings, radius, threshold):
Interviewer

Your question is Anomaly Detection for Furnace Data. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.