Monday, December 1, 2014

Lowest Common Ancestor of a Binary Tree

geeksforgeeks

leetcode

Lowest Common Ancestor of  binary search tree


Lowest Common Ancestor of a Binary Tree with parent pointer:

way 1, use a hashmap to record a path to root until find a node that is already inserted in the map.
way 2, get the height of the two nodes, compute the difference.

No comments:

Post a Comment