DSC-Banasthali-Vidyapith / Code-Crossroad

This project contains the carefully compiled Data Structures & Algorithm questions asked by the companies that visit Banasthali Vidyapith on-campus.
MIT License
55 stars 78 forks source link

Lowest Common Ancestor of a Binary Tree #81

Closed Karnika06 closed 2 years ago

Karnika06 commented 3 years ago

Aim

Details

I would very much like to work on this issue. Its a question from LeetCode June challenge and also often comes in interviews. I would like to use JAVA language for this problem. Please assign this issue to me.

ayushi-manmohan commented 3 years ago

Aim: To find the lowest common ancestor (LCA) of two given nodes in a binary tree.

Details Recursive Approach - I will be solving it using Recursive approach. I will recursively look for any of the two nodes and return it. The least common ancestor would then be the node for which both the subtree recursions return a non-NULL node.

I wish to work on this problem in Java language. Please assign this to me.