mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-06 23:28:29 +08:00
添加0127.单词接龙的Java版本双向BFS代码,0827.最大人工岛的Java版本,0841.钥匙和房间的Java版本的BFS代码
This commit is contained in:
@ -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) {
|
||||
|
@ -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>
|
||||
|
||||
|
Reference in New Issue
Block a user