Given a binary tree(not a binary search tree) find the LCA of the 2 given nodes.

The lowest common ancestor(LCA) for the nodes u and

Approach:

Lets consider the below tree

LCA of node 30, 5 is 100

LCA of node 15, 50 is 50

and so on

The lowest common ancestor(LCA) for the nodes u and

*v*is defined as the lowest node w in*tree*that has both u and v as the descendants (where a node can be a descendant of itself).Approach:

Lets consider the below tree

LCA of node 30, 5 is 100

LCA of node 15, 50 is 50

and so on