跟上一题127一样,但是额外要求要输出搜索的路径,而且是 所有的路径
所以需要考虑将路径转换为有向图,然后将有向图中的最短路径全部枚举出来
graph的话我们通过map<string,list<string>>来记录节点和从节点出发可以到达的其他节点,
class Solution {
public List<List<String>> findLadders(String beginWord, String endWord, List<String> wordList) {
int L = beginWord.length();
// preprocessing for the intermediate words
// the adjacency map provides the adjacent words index for the words in wordList
Map<Integer, List<Integer>> neighbors = new HashMap<>();
List<String> newWordList = new ArrayList<>();
newWordList.add(beginWord);
for (String word : wordList) {
if (!wor