Find a shortest path in a directed graph that can visit each vertex at least once. Not TSP (no visit restriction and no cycle requirement)
Simply do DFS.
The path length will always be N, where N is the number of nodes in the graph.
If DFS finds disconnected graph that means there is no such path.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.