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

Function getNeighbors

javascript/0417-pacific-atlantic-water-flow.js:127–138  ·  view source on GitHub ↗
(row, rows, col, cols)

Source from the content-addressed store, hash-verified

125};
126
127var getNeighbors = (row, rows, col, cols) =>
128 [
129 [0, 1],
130 [0, -1],
131 [1, 0],
132 [-1, 0],
133 ]
134 .map(([_row, _col]) => [row + _row, col + _col])
135 .filter(
136 ([_row, _col]) =>
137 0 <= _row && _row < rows && 0 <= _col && _col < cols,
138 );
139
140/**
141 * https://leetcode.com/problems/pacific-atlantic-water-flow/

Callers 2

dfsFunction · 0.70
checkNeighborFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected