Java Simple PreOrder Traversal Solution
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 * TreeNod
# 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> res;\n\n    private TreeNode solve(TreeNode root, boolean is_root, Set<Integer> set) {\n        // edge\n        if (root == null) {\n            return null;\n        }\n\n        boolean del = set.contains(root.val);\n        if (is_root && !del) {\n            res.add(root);\n        }\n        root.left = solve(root.left, del, set);\n        root.right = solve(root.right, del, set);\n        return del ? null : root;\n    }\n\n    public List<TreeNode> delNodes(TreeNode root, int[] to_delete) {\n        Set<Integer> set = new HashSet<>();\n        for (int td : to_delete) {\n            set.add(td);\n        }\n\n        res = new ArrayList<>();\n        solve(root, true, set);\n        return res;\n    }\n}\n```
['Array', 'Hash Table', 'Binary Search', 'Tree', 'Depth-First Search', 'Binary Search Tree', 'Recursion', 'Binary Tree', 'Java']