Binary Tree Pruning LeetCode solution in Java
1class Solution {2public TreeNode pruneTree(TreeNode root) {34if (root == null) return root;56root.left = pruneTree(root.left);7root.right = pruneTree(root.right);89if (root.left == null && root.right == null && root.val == 0) return null;10else return root;11}12}