Simple DFS Solution || Beats others
\n\n# Code\n\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNod
\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass FindElements {\npublic:\n    TreeNode* curr;\n    FindElements(TreeNode* root) {\n        curr=root;\n    }\n    bool findVal(TreeNode*root,int val,int x){\n        if(!root)return false;\n        if(val==0)return true;\n        root->val=x;\n        if(root->val==val)return true;       \n        return findVal(root->left,val,(2*root->val)+1)||  findVal(root->right,val,(2*root->val)+2);\n    }\n    \n    bool find(int target) {\n        return findVal(curr,target,0);\n    }\n};\n\n/**\n * Your FindElements object will be instantiated and called as such:\n * FindElements* obj = new FindElements(root);\n * bool param_1 = obj->find(target);\n */\n```
['Depth-First Search', 'C++']