C++ Recursive
\nTreeNode* delNodes(TreeNode* root, unordered_set<int>& to_del, vector<TreeNode*>& res) {\n  if (root != nullptr) {\n    root->left = delNodes(root->left, to_d
```\nTreeNode* delNodes(TreeNode* root, unordered_set<int>& to_del, vector<TreeNode*>& res) {\n  if (root != nullptr) {\n    root->left = delNodes(root->left, to_del, res);\n    root->right = delNodes(root->right, to_del, res);\n    if (to_del.find(root->val) != end(to_del)) {\n      if (root->left != nullptr) res.push_back(root->left);\n      if (root->right != nullptr) res.push_back(root->right);\n      root = nullptr;\n    }\n  }\n  return root;\n}\nvector<TreeNode*> delNodes(TreeNode* root, vector<int>& to_del) {\n  vector<TreeNode*> res;\n  root = delNodes(root, unordered_set<int>() = unordered_set<int>(begin(to_del), end(to_del)), res);\n  if (root != nullptr) res.push_back(root);\n  return res;\n}\n```
[]