leetcode449.py
def deserialize(self, data):
        """Decodes your encoded data to tree.

        :type data: str
        :rtype: TreeNode
        """

        if not data:
            return None

        strings = data.split('#')

        def insert(x, node):
            if x < node.val:
                if not node.left:
                    node.left = TreeNode(x)
                else:
                    insert(x, node.left)
            elif x > node.val:
                if not node.right:
                    node.right = TreeNode(x)
                else:
                    insert(x, node.right)
            else:
                node.right = TreeNode(x)

        t = TreeNode(int(strings[0]))
        for i in range(1, len(strings)):
            insert(int(strings[i]), t)

        return t
Decodes your encoded data to tree.

        :type data: str
        :rtype: TreeNode
        
Decodes your encoded data to tree.
Decodes your encoded data to tree .
def deserialize(self, data):
        if not data:
            return None
        strings = data.split('#')
        def insert(x, node):
            if x < node.val:
                if not node.left:
                    node.left = TreeNode(x)
                else:
                    insert(x, node.left)
            elif x > node.val:
                if not node.right:
                    node.right = TreeNode(x)
                else:
                    insert(x, node.right)
            else:
                node.right = TreeNode(x)
        t = TreeNode(int(strings[0]))
        for i in range(1, len(strings)):
            insert(int(strings[i]), t)
        return t
def deserialize ( self , data ) : if not data : return None strings = data . split ( '#' ) def insert ( x , node ) : if x < node . val : if not node . left : node . left = TreeNode ( x ) else : insert ( x , node . left ) elif x > node . val : if not node . right : node . right = TreeNode ( x ) else : insert ( x , node . right ) else : node . right = TreeNode ( x ) t = TreeNode ( int ( strings [ 0 ] ) ) for i in range ( 1 , len ( strings ) ) : insert ( int ( strings [ i ] ) , t ) return t
Decodes your encoded data to tree.
Decodes your encoded data to tree .
"""Decodes your encoded data to tree.

        :type data: str
        :rtype: TreeNode
        """
None
TreeNode
self
data