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
Implement GPS Tracker and Speed Computation
00:00
5 left

Implement GPS Tracker and Speed Computation

HardPython

Problem

Implement a GPS tracker (the tracker emits geographic coordinates at arbitrary time intervals) that determines the fastest speed within a given distance or time window (object-oriented design).

Asked in the first interview stage. The task combines object-oriented design with implementation.

Implement fastest_speed(readings, max_distance_km, max_time_seconds). Each reading is [latitude, longitude, timestamp_seconds], ordered by timestamp. For every pair of readings with a positive time difference, consider the pair when its distance is at most max_distance_km or its elapsed time is at most max_time_seconds. Return the greatest average speed in km/h, rounded to six decimal places. Return 0.0 when no pair qualifies.

Examples: [0,0,0] and [0,0.01,60] produce 66.716956 km/h. Identical coordinates produce 0.0.

Constraints: 1 <= len(readings) <= 1000; valid GPS coordinates; timestamps are nondecreasing.

Constraints

  • 1 <= len(readings) <= 1000
  • Each reading has the form [latitude, longitude, timestamp_seconds]
  • -90 <= latitude <= 90
  • -180 <= longitude <= 180
  • Timestamps are nondecreasing
  • max_distance_km >= 0 and max_time_seconds >= 0

Function Signature

def fastest_speed(readings, max_distance_km, max_time_seconds):
Interviewer

Your question is Implement GPS Tracker and Speed Computation. 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.