Guest User

Untitled

a guest
Jan 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. class Solution {
  2. public:
  3. TreeNode* insertIntoBST(TreeNode* root, int val) {
  4. if (root == nullptr) return new TreeNode(val);
  5. if (val < root->val) {
  6. root->left = insertIntoBST(root->left, val);
  7. } else {
  8. root->right = insertIntoBST(root->right, val);
  9. }
  10. return root;
  11. }
  12. };
Add Comment
Please, Sign In to add comment