1class Solution {2public:3TreeNode *trimBST(TreeNode *root, int low, int high) {4if (!root) return NULL;56root->left = trimBST(root->left, low, high);7root->right = trimBST(root->right, low, high);89if (root->val < low) {10if (root->right) {11TreeNode *temp = root;12// delete root;13return temp->right;14} else {15return NULL;16}17}18if (root->val > high) {19if (root->left) {20TreeNode *temp = root;21// delete root;22return temp->left;23} else {24return NULL;25}26}27return root;28}29};