Java Recursion
\nList<TreeNode> heads = new ArrayList<>();\n    Set<Integer> set = new HashSet<>();\n    public List<TreeNode> delNodes(TreeNode root, int[] d) {\n        for 
```\nList<TreeNode> heads = new ArrayList<>();\n    Set<Integer> set = new HashSet<>();\n    public List<TreeNode> delNodes(TreeNode root, int[] d) {\n        for (int i : d){\n            set.add(i);\n        }\n        dfs(root, true);\n        return heads;\n    }\n    \n    private boolean dfs(TreeNode node, boolean head) {\n        if (node == null) return false;\n        boolean del = set.contains(node.val);\n        if (head && !del) {\n            heads.add(node);\n        }\n        if (dfs(node.left, del)) node.left = null;\n        if (dfs(node.right, del)) node.right = null;\n        return del;\n    }\n```
[]