Insert into a Binary Search Tree LeetCode solution in JavaScript

1
var insertIntoBST = function (root, val) {
2
if (root == null) {
3
return new TreeNode(val);
4
}
5

6
if (val < root.val) {
7
root.left = insertIntoBST(root.left, val);
8
} else {
9
root.right = insertIntoBST(root.right, val);
10
}
11

12
return root;
13
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0