We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My solution was straight forward. keep going down the tree till both values change paths. They will have new ancestors each time the go down the tree and same path. the moment they separate ways is when you return that node at which they separated
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Binary Search Tree : Lowest Common Ancestor
You are viewing a single comment's thread. Return to all comments →
My solution was straight forward. keep going down the tree till both values change paths. They will have new ancestors each time the go down the tree and same path. the moment they separate ways is when you return that node at which they separated