package leetcode;

/**
 * https://leetcode.com/problems/delete-leaves-with-a-given-value/
 */
public class Problem1325 {
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    public TreeNode removeLeafNodes(TreeNode root, int target) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1325 prob = new Problem1325();

        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(2);
        root.left.left = new TreeNode(2);
        root.right = new TreeNode(3);
        root.right.left = new TreeNode(2);
        root.right.right = new TreeNode(4);

        System.out.println(prob.removeLeafNodes(root, 2));
    }
}

@@ -355,291 +355,174 @@
     
-// TODO%0A        return null;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1325 prob = new Problem1325();%0A%0A        TreeNode root = new TreeNode(1);%0A        root.left = new TreeNode(2);%0A        root.left.left = new TreeNode(2);%0A        root.right = new TreeNode(3
+if (root == null) %7B%0A            return root;%0A        %7D%0A        root.left = removeLeafNodes(root.left, target);%0A        root.right = removeLeafNodes(root.right, target
 );%0A 
@@ -532,25 +532,45 @@
     
+if (
 root.
-righ
+val == target && roo
 t.left =
  new
@@ -569,128 +569,94 @@
 ft =
+=
  n
-ew TreeNode(2);%0A        root.right.right = new TreeNode(4);%0A%0A        System.out.println(prob.removeLeafNodes(root, 2))
+ull && root.right == null) %7B%0A            return null;%0A        %7D%0A        return root
 ;%0A  

Solve problem 1325