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.
// Write your code here.inttemp1=v1;inttemp2=v2;v1=min(temp1,temp2);v2=max(temp1,temp2);if(v1<root->data&&v2>root->data){returnroot;}else{if(v1>root->data){returnlca(root->right,v1,v2);}elseif(v2<root->data){returnlca(root->left,v1,v2);}}returnroot;}
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 →
Simple cpp solution