MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / exploreIslandDFS

Function exploreIslandDFS

javascript/0934-shortest-bridge.js:14–34  ·  view source on GitHub ↗
(row, col)

Source from the content-addressed store, hash-verified

12 let queue = [];
13
14 const exploreIslandDFS = (row, col) => {
15 if (
16 row < 0 ||
17 row >= rows ||
18 col < 0 ||
19 col >= cols ||
20 grid[row][col] !== 1
21 ) {
22 return false;
23 }
24
25 queue.push([row, col]);
26 grid[row][col] = 2;
27
28 exploreIslandDFS(row - 1, col);
29 exploreIslandDFS(row + 1, col);
30 exploreIslandDFS(row, col - 1);
31 exploreIslandDFS(row, col + 1);
32
33 return true;
34 };
35
36 const buildBridgeBFS = () => {
37 let distance = -1;

Callers 1

shortestBridgeFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected