There are few possible solutions:

#### (1) Use hash set to keep those visited value for fast lookup.

-- It can be applied to any kinds of tree. Time/Space: n/n

#### (2) Dump values to array list in-order and search by the way just like in 2sum.

-- Time/Space: n/n

#### (3) Use the stack and search just like 2sum without dumping all the value out in the beginning.

-- Time/Space: n/logn in average

If I have to choose one from them, I would prefer the **third** one because it takes advantage of the property of BST and is with lower space complexity in average. Its code is shown below.

```
public boolean findTarget(TreeNode root, int k) {
if(root == null) return false;
Stack<TreeNode> l_stack = new Stack<>();
Stack<TreeNode> r_stack = new Stack<>();
stackAdd(l_stack, root, true);
stackAdd(r_stack, root, false);
while(l_stack.peek() != r_stack.peek()){
int n = l_stack.peek().val + r_stack.peek().val;
if(n == k){
return true;
}else if(n > k){
stackNext(r_stack, false);
}else{
stackNext(l_stack, true);
}
}
return false;
}
private void stackAdd(Stack<TreeNode> stack, TreeNode node, boolean isLeft){
while(node != null){
stack.push(node);
node = (isLeft) ? node.left : node.right;
}
}
private void stackNext(Stack<TreeNode> stack, boolean isLeft){
TreeNode node = stack.pop();
if(isLeft){
stackAdd(stack, node.right, isLeft);
}else{
stackAdd(stack, node.left, isLeft);
}
}
```