# Find Elements In A Contaminated Binary Tree: Interview Notes
Find Elements In A Contaminated Binary Tree shows up often in coding rounds. Here is how I talk through it when the interviewer is watching.
## Key idea
A tree's values were wiped to -1. The original rooted at 0, with left=2*x+1 and right=2*x+2. Recover values with a DFS/BFS from 0 and store them in a hash set; find(target) is a set lookup.
## Steps to say out loud
1. Restate the input and the exact ask, and nail down constraints and overflow.
2. Name the pattern (binary search on the answer, monotonic stack or deque, interval / interval-DP, string hashing, graph traversal, or shortest paths) and why a nested scan or naive search fails.
3. Code it, then trace a short example plus one empty or already-solved edge case.
## Complexity
O(n) recover, O(1) find.
## Common mistake
Recomputing the whole tree on every find, or using 2*x / 2*x+1 (heap indexing) instead of 2*x+1 / 2*x+2.
## Practice tip
Time yourself: two minutes to explain, ten to code, three to test edges. Disclosure: I work on Linkjob AI. I also keep a practice cheat sheet at AI interview assistant.