Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

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.