Challenge: Insertion

Let’s insert an integer into a BST.

Problem

Insert an integer into a binary search tree.

Input

A BST and an integer.

Output

A binary search tree with a new value.

Sample input

6 
4
2
5 
1 
3 
8 
7 
9 
10

Sample output

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.