Graph Valid Tree
Recognize the pattern
Brute force idea
If you approach Graph Valid Tree in the most literal way possible, you get this: Check both connectivity (BFS/DFS) and acyclicity (Union-Find) separately — works but redundant. It is a fair place to begin because it matches the surface of the question, yet it does not capture the deeper structure that makes the problem simpler.
Better approach
A calmer way to see Graph Valid Tree is this: A graph is a tree iff it has exactly n-1 edges AND is connected. Check edge count, then BFS/DFS to verify connectivity. Or use Union-Find: if any edge creates a cycle, it's not a tree. The goal is not to be clever for its own sake, but to remember the one relationship that keeps the solution grounded as you move forward.
Key invariant
The truth you want to protect throughout Graph Valid Tree is this: Three equivalent conditions for a tree: (1) connected + acyclic, (2) connected + n-1 edges, (3) acyclic + n-1 edges. Any two of {connected, acyclic, n-1 edges} implies the third. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Watch out for
A common way to get lost in Graph Valid Tree is this: Only checking n-1 edges without connectivity — a forest (disconnected acyclic graph) also has n-1 edges per component but isn't a single tree. Most mistakes here are not about syntax; they come from losing track of what your state, pointer, or structure is supposed to mean.