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

Function checkNeighbors

javascript/0286-walls-and-gates.js:82–93  ·  view source on GitHub ↗
(rooms, queue)

Source from the content-addressed store, hash-verified

80};
81
82const checkNeighbors = (rooms, queue) => {
83 const [rows, cols] = [rooms.length, rooms[0].length];
84 const [row, col] = queue.dequeue();
85
86 for (const [_row, _col] of getNeighbors(row, rows, col, cols)) {
87 const isINF = rooms[_row][_col] === 2147483647; /* (2 ** 31) - 1 */
88 if (!isINF) continue;
89
90 rooms[_row][_col] = rooms[row][col] + 1;
91 queue.enqueue([_row, _col]);
92 }
93};
94
95var getNeighbors = (row, rows, col, cols) =>
96 [

Callers 1

bfsFunction · 0.70

Calls 1

getNeighborsFunction · 0.70

Tested by

no test coverage detected