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
Optimize Aptive Technician Route
00:00
5 left

Optimize Aptive Technician Route

HardPython

Problem

Aptive Environmental wants to optimize a simplified technician schedule for a single day. Given travel times between stops, implement a function that returns the minimum total travel cost to start at the Aptive branch, visit every assigned stop exactly once, and return to the branch.

Formal Specification

Write a function optimize_aptive_route(travel_times) where:

  • travel_times is an n x n matrix of non-negative integers
  • travel_times[i][j] is the cost to travel from stop i to stop j
  • stop 0 is the Aptive branch (start and end)
  • the function returns an integer: the minimum possible total route cost

If travel_times is empty, return 0. If the matrix is not square, contains negative values, or has inconsistent row lengths, raise ValueError.

Constraints

  • 0 <= n <= 12
  • travel_times is an n x n matrix
  • 0 <= travel_times[i][j] <= 10^6 for valid inputs
  • Stop 0 is the Aptive branch and must be the start and end
  • The matrix may be asymmetric

Function Signature

def optimize_aptive_route(travel_times):
Interviewer

Your question is Optimize Aptive Technician Route. 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.