Java, simple solution
Intuition\n Describe your first thoughts on how to solve this problem. \nPost order. First delete the children, then the parent. That allows for cascading delet
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nPost order. First delete the children, then the parent. That allows for cascading delete\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWhen a node is deleted, add its non-null children to the result list\nReturn a boolean indicating if a node is removed, so that its parent can set the pointer to null.\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\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    List<TreeNode> forrest;\n    boolean[] del;\n\n    public List<TreeNode> delNodes(TreeNode root, int[] to_delete) {\n        forrest = new ArrayList<>();\n        del = new boolean[1001];\n        for (int i : to_delete) del[i] = true;\n        if (!dfs(root)) forrest.add(root);\n        return forrest;\n    }\n\n    boolean dfs(TreeNode root) {\n        if (root == null) return true;\n        if (dfs(root.left)) root.left = null;\n        if (dfs(root.right)) root.right = null;\n        if (del[root.val]) {\n            if (root.left != null) forrest.add(root.left);\n            if (root.right != null) forrest.add(root.right);\n            return true;\n        }\n        return false;\n    }\n}\n```
['Java']