PythiloHard · 40 min · Task 98 of 100 · progress kept in this browser

Shortest walk visiting every vertex

Return the fewest edges in a walk visiting every vertex of an undirected graph represented by adjacency lists. Start anywhere, revisit vertices if needed, and return -1 if disconnected. Empty graph returns zero.

mask = 0b0011
next_node = 2
print(bin(mask | (1 << next_node)))
Your task

Return the fewest edges in a walk visiting every vertex of an undirected graph represented by adjacency lists. Start anywhere, revisit vertices if needed, and return -1 if disconnected. Empty graph returns zero.