# Two Sum IV Input Is A BST: Walkthrough

Two Sum IV Input Is A BST is a common tree question in coding rounds. Below is how I talk through it in an interview setting.

## Key idea

Inorder traversal yields a sorted list; then run two pointers from both ends, or keep a hash set during DFS.

## Steps to say out loud

1. Restate the input and output, and ask about empty trees and duplicate values.
2. Name the traversal (DFS or BFS) and what each call returns.
3. Code it, then trace a three-node example by hand.

## Complexity

O(n) time, O(n) space (O(h) with BST iterators from both ends).

## Common mistake

Forgetting that the same node cannot be used twice when target is 2*val.

## Practice tip

Time yourself: two minutes to explain, ten to code, three to test edge cases. Disclosure: I work on Linkjob AI. I also keep a practice cheat sheet at Linkjob AI.