Created
January 23, 2019 01:39
-
-
Save ttsugriy/4a24bdd0efd1957e5211d329fb7951e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution { | |
| public: | |
| TreeNode* insertIntoBST(TreeNode* root, int val) { | |
| if (root == nullptr) return new TreeNode(val); | |
| if (val < root->val) { | |
| root->left = insertIntoBST(root->left, val); | |
| } else { | |
| root->right = insertIntoBST(root->right, val); | |
| } | |
| return root; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment