# Height Of Binary Tree After Subtree Removal Queries: Walkthrough
Height Of Binary Tree After Subtree Removal Queries shows up often in coding rounds. Here is how I talk through it when the interviewer is watching.
## Key idea
For each query node, return the height of the tree after deleting that node's subtree. Precompute, for every node, the height of its subtree and the best 'height contribution from the rest of the tree' via a reroot / two-pass (track the top two child heights at each node).
## 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 + q).
## Common mistake
Recomputing the height with a full DFS per query (too slow) or returning the original height minus the deleted subtree height (wrong when another branch was already taller).
## 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 the Linkjob AI app.