You are viewing a single comment's thread. Return to all comments →
Node *lca(Node *root, int v1,int v2) {
if(v1>root->data && v2>root->data) root = lca(root->right,v1,v2); if(v1<root->data && v2<root->data) root = lca(root->left,v1,v2); return root; }
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 →
Node *lca(Node *root, int v1,int v2) {