添加0127.单词接龙的Java版本双向BFS代码,0827.最大人工岛的Java版本,0841.钥匙和房间的Java版本的BFS代码

This commit is contained in:
StriveDD
2023-03-02 14:50:46 +08:00
parent 453fa147c9
commit 987bad6d74
2 changed files with 5 additions and 3 deletions

View File

@ -134,9 +134,8 @@ public int ladderLength(String beginWord, String endWord, List<String> wordList)
}
```
## Java 双向BFS
```java
// Java 双向BFS
class Solution {
// 判断单词之间是否之差了一个字母
public boolean isValid(String currentWord, String chooseWord) {

View File

@ -273,7 +273,9 @@ class Solution {
return true;
}
}
```
```Java
// 广度优先搜索
class Solution {
public boolean canVisitAllRooms(List<List<Integer>> rooms) {
@ -294,7 +296,9 @@ class Solution {
return true;
}
}
```
```java
// 广度优先遍历(时间优化)
class Solution {
public boolean canVisitAllRooms(List<List<Integer>> rooms) {
@ -459,4 +463,3 @@ function canVisitAllRooms(rooms: number[][]): boolean {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>