(graph, visited, queue)
| 89 | }; |
| 90 | |
| 91 | const checkNeighbor = (graph, visited, queue) => { |
| 92 | const node = queue.dequeue(); |
| 93 | |
| 94 | for (const neighbor of graph[node]) { |
| 95 | if (visited.has(neighbor)) continue; |
| 96 | visited.add(neighbor); |
| 97 | |
| 98 | queue.enqueue(neighbor); |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | /** |
| 103 | * https://leetcode.com/problems/graph-valid-tree/ |