This question was asked to me in an interview: I have a binary tree and I have to find the common ancestor (parent) given two random nodes of that tree. I am also given a point
Maybe silly approach:
Generate the path from each node to the root, storing it as a string of "L" and "R".
Reverse these strings. Take the longest common prefix - you now have the path to the common ancestor.