Code RoomTraveling salesman
HardPrep Room Coding #1286

Traveling salesman

CodingAlgorithms & data structuresSenior–Staff~35 min

Given a complete directed graph as an n x n distance matrix dist (dist[i][j] is the cost from city i to city j, dist[i][i]=0), find the minimum cost of a tour that starts at city 0, visits every city exactly once, and returns to city 0 (closed Traveling Salesman). Return that minimum cost. Constraints: 1 <= n <= 13, 0 <= dist[i][j] <= 10000.

Implement
tsp_min_tour(dist: list[list[int]]) → int
Examples
in[[[0,10,15,20],[10,0,35,25],[15,35,0,30],[20,25,30,0]]]out80
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 35 min
InputExpectedGot
[[[0,10,15,20],[10,0,35,25],[15,35,0,30],[20,25,30,0]]]80not run yetsample