MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / exploreIsland

Function exploreIsland

number_of_islands_200/solution.go:18–40  ·  view source on GitHub ↗
(grid [][]byte, r int, c int)

Source from the content-addressed store, hash-verified

16}
17
18func exploreIsland(grid [][]byte, r int, c int) {
19 grid[r][c] = 0
20
21 // north
22 if r-1 > -1 && grid[r-1][c] == 1 {
23 exploreIsland(grid, r-1, c)
24 }
25
26 // east
27 if c+1 < len(grid[r]) && grid[r][c+1] == 1 {
28 exploreIsland(grid, r, c+1)
29 }
30
31 // south
32 if r+1 < len(grid) && grid[r+1][c] == 1 {
33 exploreIsland(grid, r+1, c)
34 }
35
36 // west
37 if c-1 > -1 && grid[r][c-1] == 1 {
38 exploreIsland(grid, r, c-1)
39 }
40}

Callers 1

numIslandsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected