package leetcode;

/**
 * https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths/
 */
public class Problem1080 {
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

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

    public TreeNode sufficientSubset(TreeNode root, int limit) {
        // TODO
        return null;
    }

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

        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(2);
        root.left.left = new TreeNode(4);
        root.left.left.left = new TreeNode(8);
        root.left.left.right = new TreeNode(9);
        root.left.right = new TreeNode(-99);
        root.left.right.left = new TreeNode(-99);
        root.left.right.right = new TreeNode(-99);
        root.right = new TreeNode(3);
        root.right.left = new TreeNode(-99);
        root.right.left.left = new TreeNode(12);
        root.right.left.right = new TreeNode(13);
        root.right.right = new TreeNode(7);
        root.right.right.left = new TreeNode(-99);
        root.right.right.right = new TreeNode(14);

        root = prob.sufficientSubset(root, 1);

        root = new TreeNode(5);
        root.left = new TreeNode(4);
        root.left.left = new TreeNode(11);
        root.left.left.left = new TreeNode(7);
        root.left.left.right = new TreeNode(1);
        root.right = new TreeNode(8);
        root.right.left = new TreeNode(17);
        root.right.right = new TreeNode(4);
        root.right.right.left = new TreeNode(5);
        root.right.right.right = new TreeNode(3);

        root = prob.sufficientSubset(root, 22);
    }
}

@@ -387,32 +387,205 @@
 rn null;%0A    %7D%0A%0A
+    private static TreeNode sufficientSubset(TreeNode root, int limit, int sum) %7B%0A        if (root == null) %7B%0A            return null;%0A        %7D%0A        return root;%0A    %7D%0A%0A
     public stati
@@ -1349,17 +1349,16 @@
 de(14);%0A
-%0A
         
@@ -1829,17 +1829,16 @@
 ode(3);%0A
-%0A
         
@@ -1876,16 +1876,799 @@
 ot, 22);
+%0A%0A        root.left = new TreeNode(2);%0A        root.left.left = new TreeNode(4);%0A        root.left.left.left = new TreeNode(8);%0A        root.left.left.right = new TreeNode(9);%0A        root.left.right = new TreeNode(-99);%0A        root.left.right.left = new TreeNode(-99);%0A        root.left.right.right = new TreeNode(-99);%0A        root.right = new TreeNode(3);%0A        root.right.left = new TreeNode(-99);%0A        root.right.left.left = new TreeNode(100);%0A        root.right.left.right = new TreeNode(13);%0A        root.right.right = new TreeNode(7);%0A        root.right.right.left = new TreeNode(-99);%0A        root.right.right.right = new TreeNode(14);%0A        root = prob.sufficientSubset(root, 1);%0A%0A        root.left = new TreeNode(5);%0A        root = prob.sufficientSubset(root, 10);
 %0A    %7D%0A%7D

Update problem 1080