O(1)  find Operation Approach 🔥
\tclass FindElements {\n\tpublic:\n    bool arr[2097152]={false}; // it is stated that max height of tree is less than 20,\n\t//so max nodes will be 2^height+1\
\tclass FindElements {\n\tpublic:\n    bool arr[2097152]={false}; // it is stated that max height of tree is less than 20,\n\t//so max nodes will be 2^height+1\n\t\n    FindElements(TreeNode* root) {\n        cure(root,0);\n    }\n    void cure(TreeNode* root,int i){\n        if(root==NULL)\n            return;\n        \n        root->val = i;\n        arr[i] = true;\n        cure(root->left,2*i+1);\n        cure(root->right,2*i+2);\n        \n    }\n    \n    bool find(int target) {\n        return arr[target]; // O(1) time complexity\n\t\t}\n\t};
[]