C++  || Simple Solution  || Tc=O(log(N)) || SC=O(1)
\n\n# Complexity\n- Time complexity:\nO(log(N))\n\n- Space complexity:\nO(log(N))\n# Code\n\nclass FindElements\n{\npublic:\n    TreeNode *root;\n    FindElemen
\n\n# Complexity\n- Time complexity:\nO(log(N))\n\n- Space complexity:\nO(log(N))\n# Code\n```\nclass FindElements\n{\npublic:\n    TreeNode *root;\n    FindElements(TreeNode *root2)\n    {\n        root = root2;\n    }\n\n    bool find(int tar)\n    {\n        stack<int> st;\n        while (tar > 0)\n        {\n            int x = 0;\n            if ((tar & 1) == 1)\n            {\n                x = 1;\n            }\n            tar--;\n            tar >>= 1;\n            st.push(x);\n        }\n        TreeNode *temp = root;\n        while (!st.empty())\n        {\n\n            if (st.top() == 1)\n            {\n                if (temp->left)\n                {\n                    temp = temp->left;\n                }\n                else\n                {\n                    return false;\n                }\n            }\n            else\n            {\n                if (temp->right)\n                {\n                    temp = temp->right;\n                }\n                else\n                {\n                    return false;\n                }\n            }\n            st.pop();\n        }\n        return true;\n    }\n};\n\n```
['C++']