Back to problems

Lowest Common Ancestor (BT / BST / N-ary)

Algorithm · Meta · Medium

Requirements Implement the lowest common ancestor operation for the following tree forms: A binary search tree, using the ordering of node values. A general binary tree, where the two target nodes may appear in different subtrees. An optional-node version in which either target might not belong to the tree; this version must only return an ancestor after confirming that both targets are present. An N-ary tree, whose nodes can have any number of children. A follow-up version…

Checking your access…