Mỹ Chu Lang
Senior Member
C#:
public class Solution {
public TreeNode PostOrder(TreeNode root, int target)
{
if(root.left != null)
root.left = PostOrder(root.left, target);
if(root.right != null)
root.right = PostOrder(root.right, target);
if(root.val == target && root.left == null && root.right == null)
return null;
else return root;
}
public TreeNode RemoveLeafNodes(TreeNode root, int target) {
root = PostOrder(root, target);
return root;
}
}
.



