Shortest transformation sequence in an unweighted graph => BFS.
Treat each word as a node; edge exists if words differ by 1 letter.
BFS from beginWord, generating neighbors by changing each character a..z and checking membership in a set.
BFS finds the shortest number of edges to reach endWord.
Shortest transformation sequence in an unweighted graph => BFS.
Treat each word as a node; edge exists if words differ by 1 letter.
BFS from beginWord, generating neighbors by changing each character a..z and checking membership in a set.
BFS finds the shortest number of edges to reach endWord.