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

Function getNeighbors

javascript/0130-surrounded-regions.js:66–77  ·  view source on GitHub ↗
(row, rows, col, cols)

Source from the content-addressed store, hash-verified

64};
65
66var getNeighbors = (row, rows, col, cols) =>
67 [
68 [0, 1],
69 [0, -1],
70 [1, 0],
71 [-1, 0],
72 ]
73 .map(([_row, _col]) => [row + _row, col + _col])
74 .filter(
75 ([_row, _col]) =>
76 0 <= _row && _row < rows && 0 <= _col && _col < cols,
77 );
78
79/**
80 * https://leetcode.com/problems/surrounded-regions/

Callers 2

dfsFunction · 0.70
bfsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected