Code RoomTraveling salesman open path
HardPrep Room Coding #1092

Traveling salesman open path

CodingAlgorithms & data structuresSenior–Staff~40 min

Given a symmetric n x n distance matrix (dist[i][j] >= 0, dist[i][i] = 0), a delivery driver starts at city 0 and must visit every city exactly once (an open Hamiltonian path, no return to 0). Return the minimum total travel distance. n is small (n <= 12). The matrix has at least one city.

Implement
tsp_min_path(dist: list[list[int]]) → int
Examples
in[[[0,10,15,20],[10,0,35,25],[15,35,0,30],[20,25,30,0]]]out65
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 40 min
InputExpectedGot
[[[0,10,15,20],[10,0,35,25],[15,35,0,30],[20,25,30,0]]]65not run yetsample