Can someone help with no attribute "deserialize" error?


  • 0
    J
    # Definition for a undirected graph node
    class UndirectedGraphNode(object):
        def __init__(self, x):
            self.label = x
            self.neighbors = []
    
    class Solution(object):
        def cloneGraph(self, s):
            """
            :type node: UndirectedGraphNode
            :rtype: UndirectedGraphNode
            """
            if not s:
                return None
            visited = {}
            queue = [s]
            while queue:
                node = queue.pop(0)
                if node not in visited:
                    nodeCopy = UndirectedGraphNode(node.label)
                    visited[node] = nodeCopy
                    for neighbor in node.neighbors:
                        neighborCopy = UndirectedGraphNode(neighbor.label)
                        nodeCopy.neighbors.append(neighborCopy)
                        queue.append(neighbor)
            return visited[s]
    

Log in to reply
 

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