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

Function getNeighbors

javascript/0994-rotting-oranges.js:61–72  ·  view source on GitHub ↗
(row, rows, col, cols)

Source from the content-addressed store, hash-verified

59};
60
61var getNeighbors = (row, rows, col, cols) =>
62 [
63 [0, 1],
64 [0, -1],
65 [1, 0],
66 [-1, 0],
67 ]
68 .map(([_row, _col]) => [row + _row, col + _col])
69 .filter(
70 ([_row, _col]) =>
71 0 <= _row && _row < rows && 0 <= _col && _col < cols,
72 );
73
74/**
75 * https://leetcode.com/problems/rotting-oranges/

Callers 1

expireFreshFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected