# All Elements In Two BSTs: Practice Notes

All Elements In Two BSTs is a common tree question in coding rounds. Below is how I talk through it in an interview setting.

## Key idea

Do two inorder traversals into sorted lists and merge them like merge sort, or step two iterative stacks in lockstep.

## 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(m+n).

## Common mistake

Sorting the concatenation works but costs a log factor; mention the merge.

## 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 https://www.linkjob.ai/.