MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / cloneGraph

Method cloneGraph

133-clone-graph/clone-graph.java:23–28  ·  view source on GitHub ↗
(Node node)

Source from the content-addressed store, hash-verified

21
22class Solution {
23 public Node cloneGraph(Node node) {
24 if (node == null) return null;
25
26 Map<Node, Node> visited = new HashMap<>();
27 return dfs(node, visited);
28 }
29
30 private Node dfs(Node node, Map<Node, Node> visited) {
31 if (visited.containsKey(node)) return visited.get(node);

Callers

nothing calls this directly

Calls 1

dfsMethod · 0.95

Tested by

no test coverage detected