Problem context and objectives
Mission briefing
Expedition navigator · Safe camps and hazards form a connected world map
Find a valid route while marking every place already explored: Valid Graph Tree.
Without visited state, the party loops forever or revisits expensive terrain.
How you win
- 1Recognize when Undirected graph tree validation matches the clues
- 2Keep this true after every move: seen contains exactly the vertices connected to node zero
- 3Reach the result within O(V + E) time and O(V) space
Rules and pressure
- Target cost: O(V + E) time and O(V) space
- State rule: seen contains exactly the vertices connected to node zero
Lesson 1 of 3
Check the structural gate first: a tree with n nodes has exactly n - 1 edges. Then send a connectivity pulse from node 0.
Your call · Five nodes and four edges pass the edge-count gate. What remains to prove?