[Rust] First thought: easy DFS + HashSet
Complexity

Time complexity:
FindElements:O(n), wherenis the size of the tree.
find:O(1)


Space complexity:
O(n)

Code
# Complexity
- Time complexity:
`FindElements`: $$O(n)$$, where $$n$$ is the size of the tree.
`find`: $$O(1)$$

- Space complexity:
$$O(n)$$

# Code
```rust []
struct FindElements {
    values: HashSet<i32>,
}

macro_rules! node_as_ref {
    ($node:expr) => {
        $node
            .as_ref()
            .map(|root| root.borrow())
            .as_ref()
            .map(|umm| &**umm)
    };
}

impl FindElements {
    fn new(root: Option<Rc<RefCell<TreeNode>>>) -> Self {
        let mut values = HashSet::new();

        fn dfs_set_node(node: Option<&TreeNode>, value: i32, values: &mut HashSet<i32>) {
            let Some(node) = node else {
                return;
            };

            values.insert(value);
            dfs_set_node(node_as_ref!(node.left), value * 2 + 1, values);
            dfs_set_node(node_as_ref!(node.right), value * 2 + 2, values);
        }
        dfs_set_node(node_as_ref!(root), 0, &mut values);

        Self { values }
    }

    fn find(&self, target: i32) -> bool {
        self.values.contains(&target)
    }
}

use std::{cell::RefCell, collections::HashSet, rc::Rc};
```
['Hash Table', 'Tree', 'Depth-First Search', 'Binary Tree', 'Rust']