Runtime error,whether the problem of recursion limit ?


  • 0
    D

    I think my algorithm is just right,but got RUNTIME ERROR when judge it.
    anyone can help me?
    python of course

    class Solution:
        # @param node, a undirected graph node
        # @return a undirected graph node
        def deep_copy(self,node):
            self.copyed.setdefault(node,None)
            if self.copyed[node]!=None:
                return self.copyed[node]
            ans = UndirectedGraphNode(node.label)
            self.copyed[node] = ans
            ans.neighbors = map(lambda x:self.deep_copy(x),node.neighbors)
            return ans
        def cloneGraph(self, node):
            if node==None:
                return None
            self.copyed = {}
            return self.deep_copy(node);

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.