python写剑指offer每次提交都是返回非0错误
python写剑指offer每次提交都是返回非0错误, 请问怎么提交,具体的格式是什么
例如:重建二叉树
我的代码
class Solution: # 返回构造的TreeNode根节点 def reConstructBinaryTree(self, pre, tin:list): print(pre, tin) if len(pre) == 0 or len(pre) == 0: return None # 先序遍历中的第一个元素为根 root = TreeNode(pre[0]) # 在tin中寻找root对应的下标 for i, v in enumerate(tin): if v == root.val: index = i # if index == 0: # index += 1 # 左子树 new_pre = pre[1:index + 1] new_tin = tin[0:index] root.left = self.reConstructBinaryTree(new_pre, new_tin) # 右子树 new_pre = pre[index + 1:len(pre)] new_tin = tin[index + 1:len(tin)] root.right = self.reConstructBinaryTree(new_pre, new_tin) return root