Intuitive C++ code beats 100% in memory
\nclass FindElements {\n    TreeNode* head=new TreeNode(-1);\npublic:\n    FindElements(TreeNode* root) {\n        head=root;\n        head->val=0;\n        rec
```\nclass FindElements {\n    TreeNode* head=new TreeNode(-1);\npublic:\n    FindElements(TreeNode* root) {\n        head=root;\n        head->val=0;\n        recover(head);\n    }\n    \n    void recover(TreeNode* root)\n    {\n        if(root->left)\n        {\n            root->left->val=(root->val)*2+1;\n            recover(root->left);\n        }\n        if(root->right)\n        {\n            root->right->val=(root->val)*2+2;\n            recover(root->right);\n        }\n        return;\n    }\n    \n    bool find(int target) {\n        return get(target,head);\n    }\n    \n    bool get(int target,TreeNode* root)\n    {\n        if(root==NULL)\n            return false;\n        if(root->val==target)\n            return true;\n        \n        bool t1=get(target,root->left);\n        bool t2=get(target,root->right);\n        \n        if(t1||t2)\n            return true;\n        return false;\n    }\n};\n```
['Recursion', 'C']