Intersection of Two Family Chains

Asked at Google · Coding Questions · Difficulty: Easy

Each node has a `parent` pointer. A "chain" is the singly linked path obtained by repeatedly following `parent` from a node up to the root. Given two starting nodes, find the first common node where their two chains intersect (their lowest common ancestor along the parent chain), or `None` if they never meet.

Loading the problem…