You are given an undirected connected graph with n nodes numbered from graph, where graph[i] contains all nodes that share an edge with node i.
Your task is to find the length of the shortest path that visits every node. You may:
Start from any node.
End at any node.
Revisit nodes and reuse edges as many times as needed.
Constraints:
n graph.length
n
graph[i].length n
graph[i] does not contain i.
If graph[a] contains b, then graph[b] contains a.
The input graph is always connected.
You are given an undirected connected graph with n nodes numbered from graph, where graph[i] contains all nodes that share an edge with node i.
Your task is to find the length of the shortest path that visits every node. You may:
Start from any node.
End at any node.
Revisit nodes and reuse edges as many times as needed.
Constraints:
n graph.length
n
graph[i].length n
graph[i] does not contain i.
If graph[a] contains b, then graph[b] contains a.
The input graph is always connected.