You are viewing a single comment's thread. Return to all comments →
for example, for a tree: 4 2 3 1 7 6 8
if you want to find the lowest common ancestor of 6 and 8, your code outputs 7, but the correct answer should be 4!
4 / \ 2 7 / \ / \ 1 3 6 8
This will be the tree, don't know what you did.
Correct answer should be 7, as tree has been presented by @latishk
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Binary Search Tree : Lowest Common Ancestor
You are viewing a single comment's thread. Return to all comments →
for example, for a tree: 4 2 3 1 7 6 8
if you want to find the lowest common ancestor of 6 and 8, your code outputs 7, but the correct answer should be 4!
This will be the tree, don't know what you did.
Correct answer should be 7, as tree has been presented by @latishk