Does this problem uses the concept of backtracking to check whether element is present on left node or right node ??
LCA 1 BInary Tree Problem
No,what you can do is pass parent in each call then check whether current node is left child of its parent or not
Hey,this is not the most optimized code.
Try to do it without extra space.
Hint:for every node,find if either left or right have both node.The first node from root that have both nodes in opposite subtree is the result.