leetcode814】的更多相关文章

We are given the head node root of a binary tree, where additionally every node's value is either a 0 or a 1. Return the same tree where every subtree (of the given tree) not containing a 1 has been removed. (Recall that the subtree of a node X is X,…
class Solution { public: TreeNode* pruneTree(TreeNode* root) { if(root==NULL) { return nullptr; } if(root->left!=NULL) { root->left = pruneTree(root->left); } if(root->right!=NULL) { root->right = pruneTree(root->right); } ) { return NUL…
""" We are given the head node root of a binary tree, where additionally every node's value is either a 0 or a 1. Return the same tree where every subtree (of the given tree) not containing a 1 has been removed. (Recall that the subtree of…