# 0814. Binary Tree Pruning ###### tags: `Leetcode` `FaceBook` `Medium` `DFS` Link: https://leetcode.com/problems/binary-tree-pruning/ ## Code ```java= class Solution { public TreeNode pruneTree(TreeNode root) { if(root == null) return null; root.left = pruneTree(root.left); root.right = pruneTree(root.right); if(root.left==null && root.right==null && root.val==0) return null; return root; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up