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

Function numIslands

number_of_islands_200/solution.go:3–16  ·  view source on GitHub ↗
(grid [][]byte)

Source from the content-addressed store, hash-verified

1package number_of_islands_200
2
3func numIslands(grid [][]byte) int {
4 count := 0
5
6 for r := 0; r < len(grid); r++ {
7 for c := 0; c < len(grid[r]); c++ {
8 if grid[r][c] == 1 {
9 count++
10 exploreIsland(grid, r, c)
11 }
12 }
13 }
14
15 return count
16}
17
18func exploreIsland(grid [][]byte, r int, c int) {
19 grid[r][c] = 0

Callers 1

Test_numIslandsFunction · 0.85

Calls 1

exploreIslandFunction · 0.85

Tested by 1

Test_numIslandsFunction · 0.68