Insert a value into a Binary Search Tree and return the root.
Constraints
Example
>>> # Example 1: Insert 5 into [4,2,7,1,3] >>> root = TreeNode(4, TreeNode(2, TreeNode(1), TreeNode(3)), TreeNode(7)) >>> insert_into_bst(root, 5).right.left.val 5 >>> # Example 2: Insert into empty tree >>> insert_into_bst(None, 5).val 5
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints