[C++] No HashMap, Bit Path
idea: Use a stack to store the bit path and then reversely find.\n\nclass FindElements {\npublic:\n    FindElements(TreeNode* root) {\n        r = root;\n      
idea: Use a stack to store the bit path and then reversely find.\n```\nclass FindElements {\npublic:\n    FindElements(TreeNode* root) {\n        r = root;\n        if (!root) return;\n        build(root, 0);\n    }\n    \n    bool find(int target) {\n        stack<bool> st;\n        int t = target;\n        while (t > 0) {\n            if (t % 2) {\n                st.push(true);\n                t = (t - 1) / 2;\n            } else {\n                st.push(false);\n                t = t / 2 - 1;\n            }\n        }\n        TreeNode *cur = r;\n        while (!st.empty()) {\n            if (!cur) return false;\n            if (st.top()) {\n                cur = cur->left;\n            } else {\n                cur = cur->right;\n            }\n            st.pop();\n        }\n        if (cur && cur->val == target) return true;\n        return false;\n    }\n    \nprivate:\n    TreeNode *r;\n    \n    void build(TreeNode* root, int val) {\n        root->val = val;\n        int n = 2 * val + 1;\n        if (root->left) build(root->left, n);\n        if (root->right) build(root->right, n + 1);\n    }\n};\n```
[]