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

Function getNeighbors

javascript/0286-walls-and-gates.js:34–45  ·  view source on GitHub ↗
(row, rows, col, cols)

Source from the content-addressed store, hash-verified

32};
33
34var getNeighbors = (row, rows, col, cols) =>
35 [
36 [0, 1],
37 [0, -1],
38 [1, 0],
39 [-1, 0],
40 ]
41 .map(([_row, _col]) => [row + _row, col + _col])
42 .filter(
43 ([_row, _col]) =>
44 0 <= _row && 0 <= _col && _row < rows && _col < cols,
45 );
46
47/**
48 * https://leetcode.com/problems/walls-and-gates/

Callers 2

dfsFunction · 0.70
checkNeighborsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected