You are viewing a single comment's thread. Return to all comments →
javascript
function lca(root, val1, val2) { if (root.data < val1 && root.data < val2) return lca(root.right, val1, val2) if (root.data > val1 && root.data > val2) return lca(root.left, val1, val2) return root.data }
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 →
javascript