File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 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) {
7676 return root ;
7777 }
7878
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-
8979 private TreeNode removeLeafNodes (int target , TreeNode root ) {
9080 if (root == null ) {
9181 return root ;
@@ -104,6 +94,16 @@ private TreeNode removeLeafNodes(int target, TreeNode root) {
10494 removeLeafNodes (target , root .right );
10595 return root ;
10696 }
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+ }
107107 }
108108
109109 public static class Solution2 {
You can’t perform that action at this time.
0 commit comments