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

Function checkNeighbor

javascript/0417-pacific-atlantic-water-flow.js:216–227  ·  view source on GitHub ↗
(heights, row, rows, col, cols, isReachable, queue)

Source from the content-addressed store, hash-verified

214 .map(() => new Array(cols).fill(false));
215
216var checkNeighbor = (heights, row, rows, col, cols, isReachable, queue) => {
217 isReachable[row][col] = true;
218
219 for (const [_row, _col] of getNeighbors(row, rows, col, cols)) {
220 if (isReachable[_row][_col]) continue;
221
222 const isLower = heights[_row][_col] < heights[row][col];
223 if (isLower) continue;
224
225 queue.enqueue([_row, _col]);
226 }
227};
228
229var getNeighbors = (row, rows, col, cols) =>
230 [

Callers 1

bfsFunction · 0.70

Calls 1

getNeighborsFunction · 0.70

Tested by

no test coverage detected