mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-11 04:54:51 +08:00
Update 0200.岛屿数量.广搜版.md
This commit is contained in:
@ -199,7 +199,9 @@ class Solution {
|
|||||||
|
|
||||||
|
|
||||||
### Python
|
### Python
|
||||||
|
|
||||||
BFS solution
|
BFS solution
|
||||||
|
|
||||||
```python
|
```python
|
||||||
class Solution:
|
class Solution:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -240,6 +242,7 @@ class Solution:
|
|||||||
|
|
||||||
```
|
```
|
||||||
### JavaScript
|
### JavaScript
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var numIslands = function (grid) {
|
var numIslands = function (grid) {
|
||||||
let dir = [[0, 1], [1, 0], [-1, 0], [0, -1]]; // 四个方向
|
let dir = [[0, 1], [1, 0], [-1, 0], [0, -1]]; // 四个方向
|
||||||
@ -324,7 +327,6 @@ function numIslands2(grid: string[][]): number {
|
|||||||
### Go
|
### Go
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
|
||||||
var DIRECTIONS = [4][2]int{{-1, 0}, {0, -1}, {1, 0}, {0, 1}}
|
var DIRECTIONS = [4][2]int{{-1, 0}, {0, -1}, {1, 0}, {0, 1}}
|
||||||
|
|
||||||
func numIslands(grid [][]byte) int {
|
func numIslands(grid [][]byte) int {
|
||||||
|
Reference in New Issue
Block a user