LeetCode 127 Word Ladder - Why Naive Fails

The trap

Try all possible paths using DFS, tracking the shortest path to endWord.

This explores many long paths before finding the shortest. With branching factor bb and depth dd, DFS explores up to bdb^d states.

BFS finds the shortest path without exploring deeper levels prematurely.