Skip to content

Commit 26c4004

Browse files
authored
Apply suggestions from code review
1 parent f6557d7 commit 26c4004

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

problems/0200.岛屿数量.深搜版.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,13 @@ func numIslands(grid [][]byte) int {
413413
}
414414

415415
func dfs(grid [][]byte, visited [][]bool, i, j int) {
416+
visited[x][y] = true
416417
for _, d := range DIRECTIONS {
417418
x, y := i+d[0], j+d[1]
418419
if x < 0 || x >= len(grid) || y < 0 || y >= len(grid[0]) {
419420
continue
420421
}
421422
if grid[x][y] == '1' && !visited[x][y] {
422-
visited[x][y] = true
423423
dfs(grid, visited, x, y)
424424
}
425425
}

0 commit comments

Comments
 (0)