Python 3 -> 82.16% faster. DFS solution
Suggestions to make it better are always welcomed.\n\n1. When solving this problem I realized, we have to lookup in to_delete everytime we are visiting any node
**Suggestions to make it better are always welcomed.**\n\n1. When solving this problem I realized, we have to lookup in to_delete everytime we are visiting any node. It\'s best to convert it to a set to do O(1) lookup.\n2. I later found out that the node made None is not known to the calling function. So, we have to pass that information using return value\n3. It\'s important that we catch the returned value and use it to disconnect the nodes.\n\n```\ndef delNodes(self, root: TreeNode, to_delete: List[int]) -> List[TreeNode]:\n\tdisjointTrees = []\n\tto_delete_nodes = set(to_delete)\n\tnode = root\n\n\tnode = self.delNodesHelper(root, to_delete_nodes, disjointTrees)\n\tif node is not None:\n\t\tdisjointTrees.append(root)\n\n\treturn disjointTrees\n\ndef delNodesHelper(self, node, to_delete_nodes, disjointTrees):\n\tif not node:\n\t\treturn None\n\n\tleftNode = self.delNodesHelper(node.left, to_delete_nodes, disjointTrees)\n\trightNode = self.delNodesHelper(node.right, to_delete_nodes, disjointTrees)\n\n\tif not leftNode:    node.left = None\n\tif not rightNode:   node.right = None\n\n\tif node.val in to_delete_nodes:\n\t\tif leftNode:    disjointTrees.append(leftNode)\n\t\tif rightNode:   disjointTrees.append(rightNode)\n\t\tnode = None\n\n\treturn node  \n```\n\n**I hope that you\'ve found this useful.\nIn that case, please upvote. It only motivates me to write more such posts\uD83D\uDE03**
['Depth-First Search', 'Python', 'Python3']