Linkage
https://leetcode.com/problems/word-ladder-ii/description/
Idea
The idea of this problem is to combine the BFS(forward) and the DFS(backward) to traverse the visited node. To be more specific, when we are searching the endWord, we should use BFS, which can trim a lot of branch compared to DFS.For reforming the ladder in backward from endWord, we need to maintain a reverse adjacent table, which will record the parent nodes of a child nodes in the BFS process.
TLE Code in Java
1 | public class Solution { |
Accept Code In C++
1 | class Solution { |