O(n) HashSet + Recursion Solution
 # Intuition  \n\n\n# Approach : Using HashSet and Recursion\n\n\n# Complexity\n- Time complexity: O(N)\n\n\n- Space complexity: O(N)\n\n\n# Code\n\n/**\n * Def
<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach : Using HashSet and Recursion\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode() {}\n *     TreeNode(int val) { this.val = val; }\n *     TreeNode(int val, TreeNode left, TreeNode right) {\n *         this.val = val;\n *         this.left = left;\n *         this.right = right;\n *     }\n * }\n */\nclass Solution {\n    public TreeNode helper(TreeNode root, List<TreeNode> list, HashSet<Integer> set) {\n        if(root == null) {\n            return null;\n        }\n        root.left = helper(root.left, list, set);\n        root.right = helper(root.right, list, set);\n        if(set.contains(root.val)) {\n            if(root.left != null) {\n                list.add(root.left);\n            }\n            if(root.right != null) {\n                list.add(root.right);\n            }\n            return null;\n        }\n        return root;\n    }\n    public List<TreeNode> delNodes(TreeNode root, int[] to_delete) {\n        List<TreeNode> list = new ArrayList<>();\n        HashSet<Integer> set = new HashSet<>();\n        for(int i : to_delete) {\n            set.add(i);\n        }\n        helper(root, list, set);\n        if(!set.contains(root.val)) {\n            list.add(root);\n        }\n        return list;\n    }\n}\n```
['Hash Table', 'Tree', 'Binary Tree', 'Java']