Code Room
CodingHard
Question
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]]) → intExamples
in
[[[0,10,15,20],[10,0,35,25],[15,35,0,30],[20,25,30,0]]]out65What 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.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.