cpp
1
2TreeNode* op(TreeNode* root, int val) {
3
4 if (root == nullptr) return new TreeNode(val);
5
6 if (val < root->val) {
7
8 root->left = op(root->left, val);
9
10 } else {
11
12 root->right = op(root->right, val);
13
14 }
15
16 return root;
17
18}
19