2
* Definition for a binary tree node.7
* TreeNode() : val(0), left(nullptr), right(nullptr) {}8
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}9
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left),15
void insertIntoMaxTreeRec(TreeNode *root, TreeNode *newNode) // o(logn)18
if (root->right && root->right->val < newNode->val) {19
newNode->left = root->right;20
root->right = newNode;25
root->right = newNode;30
insertIntoMaxTreeRec(root->right, newNode);32
TreeNode *insertIntoMaxTree(TreeNode *root, int val) {33
TreeNode *curr = new TreeNode(val);35
if (root->val < val) {39
insertIntoMaxTreeRec(root, curr);