Javascript Solution
After reading @lee215\'s post, I re-wrote mine and improved the runtime from 84ms to 72ms.\n\nUpdated version\n\nvar delNodes = function(root, to_delete) {\n   
After reading @lee215\'s [post](https://leetcode.com/problems/delete-nodes-and-return-forest/discuss/328853/javapython-recursion-solution), I re-wrote mine and improved the runtime from 84ms to 72ms.\n\n*Updated version*\n```\nvar delNodes = function(root, to_delete) {\n    if(!root) return [];\n    let res = [];\n    let traverse = (node, isRoot) => {\n        if(!node) return;\n        let isNodeDeleted = to_delete.includes(node.val);\n        if(node.left) node.left = traverse(node.left, isNodeDeleted);\n        if(node.right) node.right = traverse(node.right, isNodeDeleted);\n        if(isRoot && !isNodeDeleted) res.push(node);\n        return isNodeDeleted ? null : node;\n    }\n    traverse(root, true);\n    return res;\n};\n```\n\n*Original version written in the contest*\n```\nvar delNodes = function(root, to_delete) {\n    if(!root) return [];\n    let res = to_delete.includes(root.val) ? [] : [root];\n    let traverse = node => {\n        if(!node) return;\n        if(to_delete.includes(node.val)){\n            if(node.left){\n                let left = traverse(node.left);\n                if(left) res.push(left);\n            }\n            if(node.right){\n                let right = traverse(node.right);\n                if(right) res.push(right);\n            }\n            return null;\n        }\n        if(node.left) node.left = traverse(node.left);\n        if(node.right) node.right = traverse(node.right);\n        return node;\n    }\n    traverse(root);\n    return res;\n};\n```
[]