File tree 1 file changed +10
-10
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -76,16 +76,6 @@ public TreeNode removeLeafNodes(TreeNode root, int target) {
76
76
return root ;
77
77
}
78
78
79
- private boolean hasTargetLeafNodes (TreeNode root , int target ) {
80
- if (root == null ) {
81
- return false ;
82
- }
83
- if (root .left == null && root .right == null && root .val == target ) {
84
- return true ;
85
- }
86
- return hasTargetLeafNodes (root .left , target ) || hasTargetLeafNodes (root .right , target );
87
- }
88
-
89
79
private TreeNode removeLeafNodes (int target , TreeNode root ) {
90
80
if (root == null ) {
91
81
return root ;
@@ -104,6 +94,16 @@ private TreeNode removeLeafNodes(int target, TreeNode root) {
104
94
removeLeafNodes (target , root .right );
105
95
return root ;
106
96
}
97
+
98
+ private boolean hasTargetLeafNodes (TreeNode root , int target ) {
99
+ if (root == null ) {
100
+ return false ;
101
+ }
102
+ if (root .left == null && root .right == null && root .val == target ) {
103
+ return true ;
104
+ }
105
+ return hasTargetLeafNodes (root .left , target ) || hasTargetLeafNodes (root .right , target );
106
+ }
107
107
}
108
108
109
109
public static class Solution2 {
You can’t perform that action at this time.
0 commit comments