Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Telemetry Stream Processing

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Telemetry Stream Processing. Start with the requirements on the right.

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.

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):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output