defDeserialize(self, s): # write code here data=s.split(',') if data[0]=='#': returnNone root=TreeNode(int(data[0])) stack=[root] i=0 while stack: node=stack.pop(0) node.left=TreeNode(int(data[i+1])) if data[i+1]!='#'elseNone node.right=TreeNode(int(data[i+2])) if data[i+2]!='#'elseNone if node.left: stack.append(node.left) if node.right: stack.append(node.right) i+=2 return root