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

Function bfs

javascript/0329-longest-increasing-path-in-a-matrix.js:231–247  ·  view source on GitHub ↗
(graph, indegree, sources, path = 0)

Source from the content-addressed store, hash-verified

229};
230
231const bfs = (graph, indegree, sources, path = 0) => {
232 while (!sources.isEmpty()) {
233 /* Time(N * M) */
234 for (let level = sources.size() - 1; 0 <= level; level--) {
235 /* Time(WIDTH) */
236 checkNeighbors(
237 graph,
238 indegree,
239 sources,
240 ); /* Space((N * M) + WIDTH) */
241 }
242
243 path += 1;
244 }
245
246 return path;
247};
248
249const checkNeighbors = (graph, indegree, sources) => {
250 const [row, col] = sources.dequeue();

Callers 1

longestIncreasingPathFunction · 0.70

Calls 3

checkNeighborsFunction · 0.70
isEmptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected