[EASY UNDERSTANDING][C++]
\nclass Solution {\npublic:\n    vector<TreeNode*> res;\n    void dfs(TreeNode* &root,vector<int>& to_delete){\n        if(root==NULL) return;\n        dfs(root
```\nclass Solution {\npublic:\n    vector<TreeNode*> res;\n    void dfs(TreeNode* &root,vector<int>& to_delete){\n        if(root==NULL) return;\n        dfs(root->left,to_delete);\n        dfs(root->right,to_delete);\n        if(find(to_delete.begin(),to_delete.end(),root->val)!=to_delete.end()){\n            if(root->left) res.push_back(root->left);\n            if(root->right) res.push_back(root->right);\n            root=NULL;\n            delete root;\n        }\n    }\n    vector<TreeNode*> delNodes(TreeNode* root, vector<int>& to_delete) {\n        if(root==NULL) return res;\n        dfs(root,to_delete);\n        if(root)\n            res.push_back(root);\n        return res;\n    }\n};\n```\n**Feel free to ask any question in the comment section.**\nI hope that you\'ve found the solution useful.\nIn that case, **please do upvote and encourage me** to on my quest to document all leetcode problems\uD83D\uDE03\nHappy Coding :)\n
['Depth-First Search', 'C', 'C++']