AAlgoLoopSpaced repetition for LeetCode

BFS / DFS

Breadth-first search explores level by level (shortest path in an unweighted graph); depth-first search goes deep first (reachability, connected components, backtracking). Both visit every node once — the choice is about order, not coverage.

27 LeetCode problems solved with the BFS / DFS pattern. Practice them with spaced repetition so the pattern sticks.

See the full solution

The complete approach, reference solutions in 5 languages, and a step-by-step visualization — then add this problem to your spaced-repetition schedule.

Start free →