AlgoMaster Logo

Shortest Path Visiting All Nodes

graph=[[1,2,3],[0],[0],[0]]
0 / 123
0123startanswer = ?dp[mask][end] — min edges to visit `mask`, ending at `end`0123mask
algomaster.io
Step:Start: Shortest Path Visiting All 4 Nodes using BFS + Bitmask DP