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
Telemetry Stream Processing
00:00
5 left

Telemetry Stream Processing

MediumPython

Problem

Arity telemetry arrives as a large iterable of vehicle readings. Implement a one-pass filter that keeps only readings from allowed vehicle types, readings within an inclusive speed range, and readings whose timestamp is strictly later than the last accepted reading for that vehicle.

Preserve the original order of accepted records. A record rejected for vehicle type or speed does not update that vehicle's last accepted timestamp. The function should return a list for straightforward evaluation, but its processing must not require sorting or multiple passes over the input.

Formal Specification

Implement filter_telemetry(records, allowed_vehicle_types, min_speed, max_speed).

  • records is an iterable of dictionaries containing vehicle_id as a string, timestamp as an integer, vehicle_type as a string, and speed as a number.
  • allowed_vehicle_types is a set of strings.
  • min_speed and max_speed are numeric bounds, inclusive.
  • Return a list containing the original record dictionaries that satisfy every condition.
  • For each vehicle, accept a record only when its timestamp is greater than that vehicle's last accepted timestamp. The first qualifying record for a vehicle is accepted.

Constraints

  • 1 <= number of records <= 10^7
  • 1 <= len(allowed_vehicle_types) <= 20
  • 0 <= min_speed <= max_speed <= 200
  • Vehicle IDs and vehicle types are non-empty strings
  • Timestamps are integers and speeds are finite numbers

Function Signature

def filter_telemetry(records, allowed_vehicle_types, min_speed, max_speed):
Interviewer

Your question is Telemetry Stream Processing. 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.