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

Function wallsAndGates

javascript/0286-walls-and-gates.js:7–18  ·  view source on GitHub ↗
(rooms)

Source from the content-addressed store, hash-verified

5 * @return {void} Do not return anything, modify rooms in-place instead.
6 */
7var wallsAndGates = function (rooms) {
8 const [rows, cols] = [rooms.length, rooms[0].length];
9
10 for (let row = 0; row < rows; row++) {
11 for (let col = 0; col < cols; col++) {
12 const isGate = rooms[row][col] === 0;
13 if (!isGate) continue;
14
15 dfs(rooms, row, col);
16 }
17 }
18};
19
20const dfs = (rooms, row, col) => {
21 const [rows, cols] = [rooms.length, rooms[0].length];

Callers

nothing calls this directly

Calls 3

dfsFunction · 0.70
searchGridFunction · 0.70
bfsFunction · 0.70

Tested by

no test coverage detected