package leetcode;

/**
 * https://leetcode.com/problems/binary-tree-pruning/
 */
public class Problem814 {
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

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

    public TreeNode pruneTree(TreeNode root) {
        // TODO
        return null;
    }

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

@@ -323,24 +323,61 @@
     
-// TODO%0A
+boolean b = prune(root);%0A        if (b) %7B%0A   
         
 retu
@@ -372,16 +372,17 @@
         
+ 
 return n
@@ -386,16 +386,47 @@
 n null;%0A
+        %7D%0A        return root;%0A
     %7D%0A%0A 
@@ -429,29 +429,30 @@
 %7D%0A%0A    p
-ublic
+rivate
  static 
 void mai
@@ -447,77 +447,449 @@
 tic 
-void main(String%5B%5D args) %7B%0A        Problem814 prob = new Problem814()
+boolean prune(TreeNode root) %7B%0A        if (root == null) %7B%0A            return true;%0A        %7D%0A        boolean b1 = prune(root.left);%0A        boolean b2 = prune(root.right);%0A        if (b1) %7B%0A            if (root.left != null) %7B%0A                root.left = null;%0A            %7D%0A        %7D%0A        if (b2) %7B%0A            if (root.right != null) %7B%0A                root.right = null;%0A            %7D%0A        %7D%0A        return root.val == 0 && b1 && b2
 ;%0A  

Solve problem 814