0%
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
class Solution: def insertIntoBST(self, root: Optional[TreeNode], val: int) -> Optional[TreeNode]: if root==None: return TreeNode(val=val) if root.val > val: root.left = self.insertIntoBST(root.left,val) elif root.val < val: root.right = self.insertIntoBST(root.right,val) return root
|