title: Lowest Common Ancestor for a given pair of nodes
body: <p>I am stumbled by this question. The following is my approach: </p>
  
  <pre><code>Lets say the two nodes are node1 and node2
  For any node (lets say node1), find the path from Root to 
        node1 and store it in an HashMap
  For the other node node2, find the path from root to node2, and while traversing back, 
        check if any of the nodes are present in the hashmap or not
  Return the first found node
  </code></pre>
  
  <p>Time Complexity is O(n) and Space Complexity is also O(h), where n is the height of the tree</p>
  
  <p>I just wanted to know how good is this approach. Or whether there exists any other better solution. </p>
  
  <p>EDIT: The given tree is Binary Tree and not BST. So, the time taken to find a node is                 linear to the size of nodes. </p>