1. 算法思想
广度优先搜索(breadth-first search, BFS) 是层层遍历的。因此,需要用先入先出的队列。
BFS常常用来处理最短路径问题。
DFS和BFS都可以处理可达性问题。DFS可以使用递归,但容易栈溢出,故DFS递归在实际工程中不常用。
2. 常见题型
LeetCode-934. Shortest Bridge [C++][Java]_贫道绝缘子的博客-CSDN博客You may change0's to1's to connect the two islands to formone island. Returnthe smallest number of0's you must flip to connect the two islands.https://blog.csdn.net/qq_15711195/article/details/123286958LeetCode-127. Word Ladder [C++][Java]_贫道绝缘子的博客-CSDN博客Atransformation sequencefrom wordbeginWordto wordendWordusing a dictionarywordListis a sequence of wordsbeginWord -> s1-> s2-> ... -> sk , return shortest sequence length.
https://blog.csdn.net/qq_15711195/article/details/122800843LeetCode-126. Word Ladder II [C++][Java]_贫道绝缘子的博客-CSDN博客Given two words,beginWordandendWord, and a dictionarywordList, returnall theshortest transformation sequencesfrombeginWordtoendWord, or an empty list if no such sequence exists. Each sequence should be returned as a list of the words[beginWord,
https://blog.csdn.net/qq_15711195/article/details/122814072