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

Function searchGrid

javascript/0286-walls-and-gates.js:59–72  ·  view source on GitHub ↗
(rooms, queue = new Queue([]))

Source from the content-addressed store, hash-verified

57};
58
59const searchGrid = (rooms, queue = new Queue([])) => {
60 const [rows, cols] = [rooms.length, rooms[0].length];
61
62 for (let row = 0; row < rows; row++) {
63 for (let col = 0; col < cols; col++) {
64 const isGate = rooms[row][col] === 0;
65 if (!isGate) continue;
66
67 queue.enqueue([row, col]);
68 }
69 }
70
71 return queue;
72};
73
74const bfs = (rooms, queue) => {
75 while (!queue.isEmpty()) {

Callers 1

wallsAndGatesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected