Recursive C++ Solution
\nclass Solution {\npublic:\n    vector<TreeNode*> delNodes(TreeNode* root, vector<int>& to_delete) {\n        vector<TreeNode*> result;\n        set<int> to_de
```\nclass Solution {\npublic:\n    vector<TreeNode*> delNodes(TreeNode* root, vector<int>& to_delete) {\n        vector<TreeNode*> result;\n        set<int> to_delete_set;\n        for (int i : to_delete)\n            to_delete_set.insert(i);\n        helper(root, result, to_delete_set, true);\n        return result;\n    }\n    \n    TreeNode* helper(TreeNode* node, vector<TreeNode*>& result, set<int>& to_delete_set, bool is_root) {\n        if (node == NULL) return NULL;\n        bool deleted = to_delete_set.find(node->val) != to_delete_set.end();\n        if (is_root && !deleted) result.push_back(node);\n        node->left = helper(node->left, result, to_delete_set, deleted);\n        node->right =  helper(node->right, result, to_delete_set, deleted);\n        return deleted ? NULL : node;\n    }\n};\n\n```
[]