Insert Into a Binary Search Tree

Medium · Binary Search Trees · about 15 minutes

Asked at Amazon, Microsoft, Apple.

Add the new value val (not yet present) to a binary search tree so the tree stays a valid BST, and return its root.

Related guides