class Solution
{
public:
TreeNode* insertIntoBST(TreeNode* root, int val)
{
//明确一个节点要做的事
if (root == nullptr) return new TreeNode(val);
if (root->val == val) return root;
//其他扔给递归循环
if (root->val > val)
root->left = insertIntoBST(root->left, val);
if(root->val < val)
root->right = insertIntoBST(root->right, val);
return root;
}
};
08-25
453