hard

Shortest Path Visiting All Nodes

Given a connected undirected graph with at most 12 nodes, find the length of the shortest walk that visits every node at least once. You may start at any node and revisit nodes and edges.

Constraints
  • 1 ≤ n ≤ 12
  • The graph is connected
Examples
in: graph = [[1,2,3],[0],[0],[0]]
out: 4
e.g. 1 → 0 → 2 → 0 → 3.

Code it yourself

Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?

Choose an approach to check your pattern recognition, or reveal the discussion when you need help.