递归判断叶子节点是否为0,若叶子节点为0则修剪返回null
class Solution {
public TreeNode pruneTree(TreeNode root) {
if(root == null) return null;
help(root);
return root;
}
public TreeNode help(TreeNode root){
if(root == null) return null;
root.left=help(root.left);
root.right=help(root.right);
if(root.val == 0&&root.left==null&&root.right==null) return null;
return root;
}
}