Here I have proposed the solution for one of the most famous interview questions asked in the "FAANG" companies in Binary Trees Data Structure which is to find the Lowest Common Ancestor of a Nodes in a BST. Here I have used "DFS" traversal technique to find the Common Parent of the given Nodes by checking whether their Child Nodes are equal to the Nodes given and if so then return that Node and if not then traverse left and right sub trees.
Here I have proposed the solution for one of the most famous interview questions asked in the "FAANG" companies in Binary Trees Data Structure which is to find the Lowest Common Ancestor of a Nodes in a BST. Here I have used "DFS" traversal technique to find the Common Parent of the given Nodes by checking whether their Child Nodes are equal to the Nodes given and if so then return that Node and if not then traverse left and right sub trees.