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

Function getNeighbors

javascript/0200-number-of-islands.js:35–46  ·  view source on GitHub ↗
(row, rows, col, cols)

Source from the content-addressed store, hash-verified

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

Callers 2

dfsFunction · 0.70
bfsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected