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
Star Path Without Crossing
00:00
5 left

Star Path Without Crossing

HardPython

Problem

Given a star, how would you reach all points without crossing over other points and only travel straight until the end?

Treat the star's points as distinct 2D coordinates. Starting at start, visit every point exactly once, and require each straight segment to avoid passing through any other point. Return the minimum-distance route as point indices, or [] if no valid route exists.

Function signature: def shortest_star_route(points, start): Input is a list of [x, y] coordinates and a starting index. Output is an ordered list of all point indices.

Constraints

  • 1 <= len(points) <= 15
  • Each point is represented as [x, y]
  • All points are distinct
  • -10^6 <= x, y <= 10^6
  • 0 <= start < len(points)
  • Each point must appear exactly once in the returned route

Function Signature

def shortest_star_route(points, start):
Interviewer

Your question is Star Path Without Crossing. 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.