GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.hackerrank.com — Binary Search Tree : Lowest Common Ancestor | HackerRank 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. You are given pointer to the root of the binary search tree and two values and . You need to return the lowest common ancestor (LCA) of and in the binary search tree.
Function Description Complete the function lca in the editor below. It should return a pointer to the lowest common ancestor node of the two values given. lca has the following parameters: Input Format The first line contains an integer, , the number of nodes in the tree. To use the test data, you will have to create the binary search tree yourself. Here on the platform, the tree will be created for you. Constraints Output Format Return the a pointer to the node that is the lowest common ancestor of and . Sample Input
and . Sample Output [reference to node 4] Explanation LCA of and is , the root in this case. Cookie support is required to access HackerRankSeems like cookies are disabled on this browser, please enable them to open this website |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |