Insert into a Binary Search Tree LeetCode solution in Python

1
class Solution:
2
def insertIntoBST(self, root, val):
3
if not root:
4
return TreeNode(val)
5

6
if val < root.val:
7
root.left = self.insertIntoBST(root.left, val)
8
else:
9
root.right = self.insertIntoBST(root.right, val)
10

11
return root

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0