Word Ladder
Intro
Word Ladder I (LC.127)
Example
I:
startWord = "hit"
endWord = "cog"
wordList = ["hot","dot","dog","lot","log","cog"]
draw the word graph
O:
5 because hit -> hot -> dot -> dog -> cog or hit -> hot -> lot -> log -> cog
I:
beginWord = "hit"
endWord = "cog"
wordList = ["hot","dot","dog","lot","log"]
O:
0 because endWord does not exit in the dictionary Level BFS
Code
Optimized BFS
Optimized Code
Bidirectional BFS
Time Complexity
Reading
Last updated