Search
⌘K

Leetcode 847. Shortest Path Visiting All Nodes

Find the minimum number of steps in a walk that visits every node of an undirected connected graph (n ≤ 12), where revisiting nodes/edges is allowed. This is solved by searching the shortest path in the augmented state space (current node, visited-node bitmask) — typically via BFS/bitmask DP over O(n·2^n) states.

Asked at:

Intuit

LinkedIn

LinkedIn

Google

Google


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late October, 2025

Intuit

Senior

Early August, 2025

LinkedIn

LinkedIn

Mid-level

Late November, 2024

Google

Google

Mid-level

Find the shortest path visiting all nodes in a graph using BFS, with a hard follow-up involving a constructive algorithm

Comments

Your account is free and you can post anonymously if you choose.