C++ Simple and Easy to Understand Recursive Solution
IntuitionRecover the tree recursively while keeping all the values in a hashmap to find them easily.Complexity

Time complexity:Recover tree - O(n)Find - O(1)
# Intuition
Recover the tree recursively while keeping all the values in a hashmap to find them easily.

# Complexity
- Time complexity:
Recover tree - O(n)
Find - O(1)

- Space complexity: O(n)

# Code
```cpp []
class FindElements {
public:
    unordered_set<int> values;

    void recover(TreeNode* root) {
        if (!root) return;

        if (root->left) {
            root->left->val = root->val * 2 + 1;
            values.insert(root->left->val);
            recover(root->left);
        }

        if (root->right) {
            root->right->val = root->val * 2 + 2;
            values.insert(root->right->val);
            recover(root->right);
        }
    }
    FindElements(TreeNode* root) {
        if (root) {
            root->val = 0;
            values.insert(0);
        }
        recover(root);
    }

    bool find(int target) {
        return values.count(target);
    }
};
```

### Like it? Please Upvote!
['C++']