MCPcopy Create free account
hub / github.com/VanjaRo/LeetCode / numIslands

Function numIslands

tasks/200.go:7–18  ·  view source on GitHub ↗
(grid [][]byte)

Source from the content-addressed store, hash-verified

5}
6
7func numIslands(grid [][]byte) int {
8 ret := 0
9 for i := range grid {
10 for j := range grid[0] {
11 if grid[i][j] == '1' {
12 dfs(i, j, &grid)
13 ret++
14 }
15 }
16 }
17 return ret
18}
19
20func dfs(i, j int, grid *[][]byte) {
21 if i < 0 || j < 0 || i >= len((*grid)) || j >= len((*grid)[0]) || (*grid)[i][j] == byte('0') {

Callers

nothing calls this directly

Calls 1

dfsFunction · 0.70

Tested by

no test coverage detected