[Java] 18ms 92% faster
The speed is obtained by not modifiying the tree and using bitwise operator\nleftshift by 1 == multiplication by 2 and it is much faster than multiplication ope
The speed is obtained by not modifiying the tree and using bitwise operator\nleftshift by 1 == multiplication by 2 and it is much faster than multiplication operator\n\nFor the fast lookup use hashmap, because the lookup time is O(1) (avg)\n```\nclass FindElements {\n\n    Set<Integer> set = new HashSet<>();\n    void solve(TreeNode root ,int NodeVal){\n        if(root == null) return;\n        set.add(NodeVal);\n        solve(root.left,(NodeVal<<1) + 1); \n        solve(root.right,(NodeVal<<1) + 2);\n    }\n    public FindElements(TreeNode root) {\n        solve(root,0);\n    }\n    \n    public boolean find(int target) {\n        return set.contains(target);\n    }\n}\n```
['Java']