https://leetcode.com/problems/clone-graph/



Runtime: 53 ms, faster than 65.14% of Python3 online submissions for Clone Graph.

Memory Usage: 14.3 MB, less than 78.34% of Python3 online submissions for Clone Graph.


```python
"""
# Definition for a Node.
class Node:
    def __init__(self, val = 0, neighbors = None):
        self.val = val
        self.neighbors = neighbors if neighbors is not None else []
"""

class Solution:
    used_node_dict = {}
    def cloneGraph(self, node: 'Node') -> 'Node':
        self.used_node_dict = {}
        
        def cloneGraph2(node: 'Node') -> 'Node':
            #8:40
            if node is None:
                return None

            if (node.val in self.used_node_dict.keys()):
                return self.used_node_dict.get(node.val)

            newNode = Node(val=node.val)
            self.used_node_dict[node.val] = newNode

            if node.neighbors is not None:
                for value in node.neighbors:
                    newNode.neighbors.append(cloneGraph2(value))

            return newNode
            #8:43
            #debug until 8:59
       
        return cloneGraph2(node)
```



Put important activities at the top of your day.

So you won't miss it.
