MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / numIslands

Method numIslands

200. Number of Islands/Solution.cpp:34–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 }
33
34 int numIslands(vector<vector<char>>& grid) {
35 m = grid.size();
36 if (m == 0) return 0;
37 n = grid[0].size();
38 if (n == 0) return 0;
39 cnt = 0;
40 g.clear();
41 for (auto & i : grid)
42 g.push_back(i);
43 for (int i = 0; i < m; i ++ ) {
44 for (int j = 0; j < n; j ++ ) {
45 if (g[i][j] == '1') {
46 cnt ++ ;
47 traverse(i, j);
48 }
49 }
50 }
51 return cnt;
52 }
53};
54
55int main() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected