算法问题,高手有请# Programming - 葵花宝典
g*t
1 楼
Given a simple binary tree, and two tree nodes A and B, how can you find the
least common ancestor of A and B in O(lgn) using only constant storage (that
means constant memory usage regardless of the size of the tree, and no node
marking)? The least common ancestor of A and B is a node C that is the
ancestor of both A and B that is furthest from the root of the tree.
least common ancestor of A and B in O(lgn) using only constant storage (that
means constant memory usage regardless of the size of the tree, and no node
marking)? The least common ancestor of A and B is a node C that is the
ancestor of both A and B that is furthest from the root of the tree.