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

Method traverse

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

Source from the content-addressed store, hash-verified

20 vector<vector<char>> g;
21
22 void traverse(int i, int j) {
23 g[i][j] = '0';
24 if (i > 0 and g[i - 1][j] == '1')
25 traverse(i - 1, j);
26 if (i < m - 1 and g[i + 1][j] == '1')
27 traverse(i + 1, j);
28 if (j > 0 and g[i][j - 1] == '1')
29 traverse(i, j - 1);
30 if (j < n - 1 and g[i][j + 1] == '1')
31 traverse(i, j + 1);
32 }
33
34 int numIslands(vector<vector<char>>& grid) {
35 m = grid.size();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected