Try this exercise. Could you figure out the right sequence for this list?
Can you put these steps in the right order to iteratively find lowest common ancestor of two BST
nodes?
Press the below buttons in the order in which they should occur. Click on them again to un-select.
Options:
- Pre-order DFS traversal through both trees to get paths from node1 and node2
- Instantiate two arrays
- At each node visit, push the path nodes to the arrays
- Compare the paths to find the first different node