leetcode1008】的更多相关文章

Return the root node of a binary search tree that matches the given preorder traversal. (Recall that a binary search tree is a binary tree where for every node, any descendant of node.left has a value < node.val, and any descendant of node.right has…
class Solution: def __init__(self): self.root = None def construct(self,order,root,i): if i==len(order): return None else: if self.root==None: self.root = TreeNode(order[i]) self.construct(order,self.root,i+1) else: if order[i]<root.val: if root.left…