Simple CPP solution
CodeThank you,
aadithya18.


# Code
```cpp []
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class FindElements {
public:
    TreeNode* tree;
    unordered_set<int> s;
    void fun(TreeNode* tree, int parentVal, bool branch){
        if(tree == NULL) return;
        if(branch) tree->val = 2*parentVal + 2;
        else tree->val = 2*parentVal + 1;
        s.insert(tree->val);
        fun(tree->left, tree->val, 0);
        fun(tree->right, tree->val, 1);
    }
    FindElements(TreeNode* root) {
        tree = root;
        tree->val = 0;
        s.insert(0);
        fun(tree->left, 0, 0);
        fun(tree->right, 0, 1);
    }

    bool find(int target) {
        // if(target>100000) return false;
        return s.find(target) != s.end();
    }
};

/**
 * Your FindElements object will be instantiated and called as such:
 * FindElements* obj = new FindElements(root);
 * bool param_1 = obj->find(target);
 */
```
Thank you,
aadithya18.
['C++']