4
given a, we can get the inorder traversal of it, then append val to it and5
then construct the tree back9
self, root: Optional[TreeNode], val: int10
) -> Optional[TreeNode]:17
inorder_list.append(root.val)21
inorder_list.append(val)23
def get_maximum(val_list):26
for i, val in enumerate(val_list):30
return max_index, max_val32
def create_tree(val_list):35
index, val = get_maximum(val_list)37
node.left = create_tree(val_list[:index])38
node.right = create_tree(val_list[index + 1 :])41
b = create_tree(inorder_list)