package leetcode;

/**
 * https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree/
 */
public class Problem1261 {
    private static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

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

    private static class FindElements {
        public FindElements(TreeNode root) {
        }

        public boolean find(int target) {
            // TODO
            return false;
        }
    }

    public static void main(String[] args) {
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 /**%0A * h
@@ -392,204 +392,541 @@
    p
-ublic FindElements(TreeNode root) %7B%0A        %7D%0A%0A        public boolean find(int target) %7B%0A            // TODO%0A            return false;%0A        %7D%0A
+rivate final Set%3CInteger%3E set = new HashSet%3C%3E();%0A%0A        public FindElements(TreeNode root) %7B%0A            traverse(root, 0, set);%0A        %7D%0A%0A        private static void traverse(TreeNode root, int value, Set%3CInteger%3E set) %7B%0A            if (root == null) %7B%0A                return;%0A            %7D%0A            set.add(value);%0A            traverse(root.left, 2 * value + 1, set);%0A            traverse(root.right, 2 * value + 2, set);%0A  
     
+  
 %7D%0A%0A    
+ 
+   
 public 
-static void main(String%5B%5D args) %7B
+boolean find(int target) %7B%0A            return set.contains(target);%0A        %7D
 %0A   

Solve problem 1261