mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 15:45:40 +08:00
Apply suggestions from code review
This commit is contained in:
@ -413,13 +413,13 @@ func numIslands(grid [][]byte) int {
|
||||
}
|
||||
|
||||
func dfs(grid [][]byte, visited [][]bool, i, j int) {
|
||||
visited[x][y] = true
|
||||
for _, d := range DIRECTIONS {
|
||||
x, y := i+d[0], j+d[1]
|
||||
if x < 0 || x >= len(grid) || y < 0 || y >= len(grid[0]) {
|
||||
continue
|
||||
}
|
||||
if grid[x][y] == '1' && !visited[x][y] {
|
||||
visited[x][y] = true
|
||||
dfs(grid, visited, x, y)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user