betterworks Interview Question

Find Least common ancestor for given tree. Each node has int value and link to parent.

Interview Answer

Anonymous

May 20, 2017

2. Another approach is calculate depth of each node and then mode the node which is more depth by depth difference. Later traverse both node pointer at the same time until both node has same parent

1