Skip to content

Commit 81df115

Browse files
authored
Create Solution.java
1 parent cf6b6ae commit 81df115

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public TreeNode pruneTree(TreeNode root) {
3+
if (root == null) {
4+
return null;
5+
}
6+
root.left = pruneTree(root.left);
7+
root.right = pruneTree(root.right);
8+
return root.val == 0 && root.left == null && root.right == null ? null : root;
9+
}
10+
}

0 commit comments

Comments
 (0)