✅Simple BFS || O(N) Efficient Solution.
IntuitionApproachComplexity
Time complexity: O(N)

Space complexity: O(N)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class FindElements {
    HashSet<Integer> set;
    public FindElements(TreeNode root) {
        set = new HashSet<>();
        root.val = 0;
        bfs(root,set);        
    }
    
    public boolean find(int target) {
        return set.contains(target);
    }
    private void bfs(TreeNode root, HashSet<Integer> set)
    {
        Queue<TreeNode> q = new LinkedList<>();
        q.add(root);
       
        while(!q.isEmpty())
        {
            TreeNode curr = q.poll();
             set.add(curr.val);
            if(curr.left!=null)
            {
                q.offer(curr.left);
                if(curr.left.val==-1)
                {
                    int act = curr.val*2 + 1;
                    curr.left.val = act;
                }
            }
             if(curr.right!=null)
            {
                q.offer(curr.right);
                if(curr.right.val==-1)
                {
                    int act = curr.val*2 + 2;
                    curr.right.val = act;
                }
            }
            
        }
    }
}

/**
 * Your FindElements object will be instantiated and called as such:
 * FindElements obj = new FindElements(root);
 * boolean param_1 = obj.find(target);
 */
```
['Hash Table', 'Tree', 'Breadth-First Search', 'Design', 'Binary Tree', 'Java']